#include #include // Common file #include // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; typedef tree, rb_tree_tag, tree_order_statistics_node_update> ordered_set; struct splitmix64_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; template using hash_map = __gnu_pbds::gp_hash_table; template using hash_set = hash_map; templateauto&operator<<(ostream&o,pairp){return o<<'('<auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<", "+2*!i++<= (b); --i) #define RI(i,n) FOR(i,1,(n)) #define REP(i,n) FOR(i,0,(n)-1) #define mini(a,b) a=min(a,b) #define maxi(a,b) a=max(a,b) #define pb push_back #define st first #define nd second #define sz(w) (int) w.size() typedef vector vi; typedef long long ll; typedef long double ld; typedef pair pii; typedef pair pll; typedef pair para; const ll inf = 1e18 + 7; const ll maxN = 1e6 + 5; const ll MOD = 1e9 + 7; // sprawdz MODULO! int main() { mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vi a(n), suf(n); vi occ(10); REP(i, n) cin >> a[i]; vi ans(n, -1); int sum = 0; FORD(i, n - 1, 0) { sum += a[i]; sum %= 10; suf[i] = sum; debug(sum, occ[sum]); if (sum == 0) { ans[i] = n - i; if (occ[sum] != 0) { ans[i] = occ[sum] - i; } } else { if (occ[sum] != 0) { ans[i] = occ[sum] - i; } else { ans[i] = -1; } } occ[sum] = i; } REP(i, n) cout << ans[i] << " "; return 0; }