#include using namespace std; typedef long long ll; typedef double lf; typedef long double Lf; typedef pair pii; typedef pair pll; #define TRACE(x) cerr << #x << " " << x << endl #define FOR(i, a, b) for (int i = (a); i < int(b); i++) #define REP(i, n) FOR(i, 0, n) #define all(x) (x).begin(), (x).end() #define _ << " " << #define fi first #define sec second #define mp make_pair #define pb push_back const int MAXN = 1e6 + 5; set pref[10]; int p[MAXN]; int main() { int n; cin >> n; int sum = 0; REP(i, n) { p[i] = sum; int x; cin >> x; sum += x; sum %= 10; pref[sum].insert(i); } REP(i, n) { auto it = pref[p[i]].lower_bound(i); if (it == pref[p[i]].end()) { cout << -1 << " "; } else { cout << (*it) - i + 1 << " "; } } return 0; }