/*{{{*/ #include #ifdef LOCAL int c_ = 0; #define cout (c_?cerr:cout) #define debug(...) \ {if(!c_++)cerr<<"\033[96;1m"; \ __VA_ARGS__; \ if(!--c_)cerr<<"\033[0m";} #else #define debug(...) {} #endif #define assrt(...) debug(\ if (not (__VA_ARGS__)) \ exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\ ) #define st first #define nd second #define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end() using namespace std; using ll = long long; using ld = long double; template < typename t > using V = vector< t >; template < typename t, size_t s > using A = array< t, s >; void print() {cout << '\n';} template< typename t, typename... v > void print(const t& a, const v&... b) {cout << a << (sizeof...(b)?" ":""); print(b...);} template< typename t > void print_range(t a, const t& b) { while (a != b) cout << (*a++) << ' '; cout << '\n';} #define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__)) #define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__)) /*}}}*/ constexpr int nax = 1e5, inf = 1e9; int n, tab[nax + 1], res[nax + 1]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 0; i < n; ++i) { cin >> tab[i]; } for (int i = n - 1; i >= 0; --i) { tab[i] += tab[i + 1]; tab[i] %= 10; } int ost[10]; for (int i = 0; i < 10; ++i) { ost[i] = inf; } ost[0] = n; for (int i = n - 1; i >= 0; --i) { if (ost[tab[i]] == inf) { res[i] = -1; } else { res[i] = ost[tab[i]] - i; } ost[tab[i]] = i; } for (int i = 0; i < n; ++i) { cout << res[i]; if (i + 1 < n) { cout << ' '; } } }