Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n. The i-th ball has color ti.

For a fixed interval (set of consecutive elements) of balls we can define a dominant color. It's a color occurring the biggest number of times in the interval. In case of a tie between some colors, the one with the smallest number (index) is chosen as dominant.

There are <image> non-empty intervals in total. For each color, your task is to count the number of intervals in which this color is dominant.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 5000) — the number of balls.

The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ n) where ti is the color of the i-th ball.

Output

Print n integers. The i-th of them should be equal to the number of intervals where i is a dominant color.

Examples

Input

4
1 2 1 2


Output

7 3 0 0 


Input

3
1 1 1


Output

6 0 0 

Note

In the first sample, color 2 is dominant in three intervals:

  * An interval [2, 2] contains one ball. This ball's color is 2 so it's clearly a dominant color. 
  * An interval [4, 4] contains one ball, with color 2 again. 
  * An interval [2, 4] contains two balls of color 2 and one ball of color 1. 



There are 7 more intervals and color 1 is dominant in all of them.
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class Div2Prob2 {
    public static void main(String[] args)
        throws Exception {
        new Div2Prob2().start();
    }

    public void start()
        throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        calc(br);
    }
    int MAXN = 0;

    void calc(BufferedReader br) throws IOException {
        int n = Integer.parseInt(br.readLine());
        MAXN = n;
        String[] split = br.readLine().split(" ");
        int[][] m = new int[n][n];
        int a[] = new int[n];
        for (int i = 0; i <= n - 1; i++) a[i] = Integer.parseInt(split[i]);
        process1(m, a, n);
    }
    
    void process1(int M[][], int A[], int N)
  {   int[] result = new int[N + 1];
      int i, j; HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        /*for (i =0; i < N; i++) {
            HashMap<Integer, Integer> map2 = new HashMap<Integer, Integer>();
            Temp t = new Temp();
            t.map = map2;
            map2.put(A[i], 1);
            t.max_color = A[i];
            map.put(i + " " + i, t);
            result[A[i]] += 1;
            }*/

        for (i = 0; i < N; i++) {
            map.clear();
            map.put(A[i], 1);
            int max_color = A[i];
            result[max_color] += 1;
            for (j = i + 1; j < N; j++) {
                map.put(A[j], map.containsKey(A[j]) == true ? map.get(A[j]) + 1 : 1);
                int freq1 = map.get(A[j]);
                int freq2 = map.get(max_color);
                max_color = freq1 < freq2 ? max_color : (freq1 > freq2 ? A[j] : Math.min(A[j], max_color));
                result[max_color] += 1;
            }
            //System.out.println(i);
            //rec(i, i + 1, N, map, A, result);

        }
        for (i = 1; i <= result.length - 1; i++) System.out.print(result[i] + " ");
  }
  
}
