#include #include using namespace std; using ll = long long; using vi = vector; using vll = vector; using pii = pair; using graph = vector; #define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__) #define all(x) begin(x), end(x) #define mp make_pair #define mt make_tuple template void initialize_matrix(vector>& matrix, int rows, int cols, T value) { assert(matrix.empty()); FOR (row, rows) matrix.emplace_back(cols, value); } void go() { int n; cin >> n; vector A(n); for (auto &i : A) cin >> i; vector last(10, -1); vector ans(n); for (int i = n - 1; i >= 0; i--) { int a = A[i]; vector next(last); FOR(j, 10) { if (last[j] == -1) continue; next[(j + a) % 10] = last[j]; } next[a] = i; swap(next, last); if (last[0] == -1) { ans[i] = -1; } else { ans[i] = last[0] - i + 1; } } for(int i : ans) cout << i << " "; cout << "\n"; } int main() { ios::sync_with_stdio(false); go(); return 0; }