#define _USE_MATH_DEFINES #include #ifdef LOC #include "debuglib.h" #else #define deb(...) #define DBP(...) #endif using namespace std; using ll = long long; using Vi = vector; using Pii = pair; #define pb push_back #define mp make_pair #define x first #define y second #define rep(i, b, e) for (int i = (b); i < (e); i++) #define each(a, x) for (auto& a : (x)) #define all(x) (x).begin(), (x).end() #define sz(x) int((x).size()) int uplg(int n) { return 32-__builtin_clz(n); } int uplg(ll n) { return 64-__builtin_clzll(n); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(18); int n; cin >> n; Vi elems(n); each(e, elems) cin >> e; int pref = 0; int last[10] = {}; each(e, elems) pref = (pref+e) % 10; each(c, last) c = n+1; Vi ans(n); for (int i = n-1; i >= 0; i--) { last[pref%10] = i+1; pref = (pref-elems[i]+10) % 10; ans[i] = last[pref]; } rep(i, 0, n) cout << (ans[i] == n+1 ? -1 : ans[i]-i) << ' '; return 0; }