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.
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
long long int lcm(long long int a, long long int b) {
  return (max(a, b) / gcd(a, b)) * min(a, b);
}
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b != 0) {
    if (b % 2 != 0) {
      res = (res * a) % 1000000007;
      b--;
    } else {
      a = (a * a) % 1000000007;
      b /= 2;
    }
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  ;
  long long int i, j, k, c = 0, n, m, d = 0, l, r, x, y, z, w, e = 0, maxim = 0;
  cin >> n;
  vector<long long int> a(n), b, f(n, 0);
  vector<pair<long long int, long long int>> v;
  map<long long int, long long int> mp1, mp2;
  set<long long int> sp;
  stack<long long int> st;
  queue<long long int> q;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    vector<long long int> f1(n, 0);
    maxim = 0;
    w = INT_MIN;
    for (j = i; j < n; j++) {
      f1[a[j] - 1]++;
      if (f1[a[j] - 1] > maxim) {
        maxim = f1[a[j] - 1];
        w = a[j] - 1;
      } else if (f1[a[j] - 1] == maxim && (a[j] - 1) < w) {
        maxim = f1[a[j] - 1];
        w = a[j] - 1;
      }
      f[w]++;
    }
  }
  for (i = 0; i < n; i++) {
    cout << f[i] << " ";
  }
  return 0;
}
