/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops")*/ #include #define bit(n, i) (((n)>>(i))&1) #define cat(x) cout << #x << " = " << x << "\n" #define pb push_back #define mp make_pair #define se second #define fi first #define inf 2000000000 #define llinf 2000000000000000000LL #define forn(i, a, b) for(ll i = (a); i <= (b); ++i) #define all(x) (x).begin(), (x).end() #define ppc(x) __builtin_popcount(x) using namespace std; typedef long long ll; typedef double ld; typedef pair i2; typedef vector vi; typedef vector vll; const int N = 1e5+9; int A[N], last[10], ans[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; forn(i, 1, n) { char c; cin >> c; A[i] = c-'0'; } last[0] = n+1; forn(i, 1, 9) last[i] = -1; for(int i = n, s = 0; i >= 1; --i) { s = (s+A[i])%10; if(last[s] == -1) { ans[i] = -1; } else { ans[i] = last[s]-i; } last[s] = i; } forn(i, 1, n) cout << ans[i] << " "; return 0; }