#include using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int sum = 0; vector A(n), B(n), cnt(10, 0); vector> post(10); for (auto &a : A) cin >> a; for (int i = n - 1; i >= 0; --i) { sum = (sum + A[i]) % 10; B[i] = sum; } for (int i = 0; i < n; ++i) post[B[i]].push_back(i); for (int i = 0; i < n; ++i) { int c = cnt[B[i]]; cnt[B[i]]++; if (c < post[B[i]].size() - 1) { cout << post[B[i]][c + 1] - post[B[i]][c]; } else if (c == post[B[i]].size() - 1 && B[i] == 0) { cout << n - i; } else { cout << -1; } cout << ' '; } cout << '\n'; }