#include using namespace std; typedef long long int ll; typedef pair pii; bool R(){return true;} template bool R(T & x, Args & ... args){return cin >> x && R(args...);} void init_io(){ios::sync_with_stdio(false);cin.tie(0);} #define PB push_back #define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++) #define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--) #define ALL(vec) (vec).begin(), (vec).end() #define MM(co, cim) memset((co), (cim), sizeof((co))) #define DEB(x) cerr << ">>> " << #x << " : " << x << endl; #define INF 1000000007 #define INFLL 4000000000000000007LL int n, a[100014]; set closest[14]; void solve () { R(n); FOR(i, 0, n) R(a[i]); int rem = 0; FOR(i, 0, n) { rem += a[i]; rem %= 10; closest[rem].insert(i); } rem = 0; FOR(i, 0, n) { rem += a[i]; rem %= 10; int target_rem = (rem - a[i] + 10) % 10; auto it = closest[target_rem].lower_bound(i); printf("%d%c", it == closest[target_rem].end() ? -1 : *it - i + 1, " \n"[i == n - 1]); } } int main () { init_io(); int T = 1; //R(T); while (T--) solve(); return 0; }