/* #pragma GCC optimize("O3,unroll-loops") */ /* #pragma GCC optimize("Ofast,unroll-loops") */ /* #pragma GCC target("avx2,popcnt") */ #include #include #include #define pb push_back #define mp make_pair #define all(a) begin(a),end(a) #define FOR(x,val,to) for(int x=(val);x pi; typedef std::vector vi; typedef std::vector vs; typedef int64_t ll; typedef uint64_t ull; #define umap unordered_map #define uset unordered_set using namespace std; using namespace __gnu_pbds; #ifdef ONLINE_JUDGE #define whatis(x) ; #endif #ifdef _WIN32 #define getchar_unlocked() _getchar_nolock() #define _CRT_DISABLE_PERFCRIT_LOCKS #endif template ostream& operator<<(ostream &os, pair P) { os<<"("< ostream& operator<<(ostream &os, map P) { for(auto const &vv: P)os<<"("< ostream& operator<<(ostream &os, set V) { os<<"[";for(auto const &vv:V)os< ostream& operator<<(ostream &os, vector V) { os<<"[";for(auto const &vv:V)os<32){str+=cur;cur=getchar_unlocked();}} template inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); } template using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound template using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>; #define N 1000001 int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; sc(n); int a[n]; GET(a); int pre[n]; pre[0] = a[0] % 10; FOR(i,1,n){ pre[i] = a[i] + pre[i-1]; pre[i] %= 10; } vi wh[10]; FOR(i,0,n){ wh[pre[i]].push_back(i); } int res[n]; FOR(i,0,n){ /* int whh = ((10 - (i ? pre[i-1] : 0)) + 20 )% 10; */ int whh = (i ? pre[i-1] : 0); auto it = lower_bound(all(wh[whh]), i); if(it == wh[whh].end()) res[i] = -1; else res[i] = *it - i + 1; } FORR(i,res) cout << i << ' '; cout << '\n'; }