import java.util.*;
import java.io.*;
import java.math.*;

public class Main {

    public static void main(String[] args) {
        //int t = f.nextInt();while(t-- > 0)
            solve();
        out.close();
    }


    static void solve() {
        int n = f.nextInt();
        int[] arr = new int[n];

        for(int i=0;i<n;i++) {
            arr[i] = f.nextInt();
        }

        for(int i=1;i<n;i++) {
            arr[i] += arr[i-1];
        }

        Queue<Integer>[] ls = new ArrayDeque[10];
        for(int i=0;i<10;i++) {
            ls[i] = new ArrayDeque();
        }
        for(int i=0;i<n;i++) {
            ls[arr[i]%10].add(i);
        }

        StringBuilder sb = new StringBuilder();
        int last = 0;
        for(int i=0;i<n;i++) {

            while (!ls[last].isEmpty() && ls[last].peek() < i) {
                ls[last].poll();
            }

            if(!ls[last].isEmpty()) {
                sb.append(ls[last].peek()-i+1);
            } else {
                sb.append(-1);
            }
            sb.append(' ');

            last = arr[i] % 10;
        }



        out.println(sb.toString());
    }

    static FastReader f = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    static class FastReader {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        String next() {
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(IOException ioe) {
                    ioe.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int  nextInt() {
            return Integer.parseInt(next());
        }

        double  nextDouble() {
            return Double.parseDouble(next());
        }

        long  nextLong() {
            return Long.parseLong(next());
        }
    }
}
