#include<iostream>
using namespace std;
int ost[10];
int ile[100007];
int out[100007];
int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	int s = 0;
	for(int i = 0; i < n; i++) cin>>ile[i];
	for(int i = 0; i < 10; i++) ost[i] = n+1;
	ost[0] = n-1;
	for(int i = n-1; i>=0; i--) {
		s += ile[i];
		s%=10;
		if(ile[i] == 0) {
			out[i] = 1;
		} else {
			if(ost[s] != n+1) {
				out[i] = ost[s] - i + 1;

			} else out[i] = n+1;
		}
		//cout<<s<<" "<<ost[s]<<endl;
		ost[s] = i - 1;
	}
	//for(int i = 0; i < n; i++) cout<<out[i]<<" ";
	//cout<<endl;
	for(int i = 0; i < n; i++) cout<<((out[i] == n+1) ? -1 : out[i])<<" ";
}
