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;
double Fib(double x, double z);
string BinDec(long long x);
string StringInt(long long x);
unsigned long long StringInt(string x);
long long BinDec(string x);
unsigned long long POWMOD(unsigned long long x, unsigned long long y,
                          unsigned long long mod);
unsigned long long POWE(long long, long long);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, i, j, k, z[6000] = {}, a[6000] = {};
  cin >> x;
  for (i = 1; i <= x; i++) cin >> z[i];
  for (i = 1; i <= x; i++) {
    int y[6000] = {}, maxi = 0;
    for (j = i; j <= x; j++) {
      y[z[j]]++;
      if (y[z[j]] == maxi && k > z[j]) {
        maxi = y[z[j]];
        k = z[j];
      }
      if (y[z[j]] > maxi) {
        maxi = y[z[j]];
        k = z[j];
      }
      a[k]++;
    }
  }
  for (i = 1; i <= x; i++) cout << a[i] << ' ';
  return 0;
}
double Fib(double x, double z) {
  int i = 0;
  double f = x, r = x, t;
  for (i = 2; i < z; i++) {
    t = f;
    f += r;
    r = t;
  }
  return f;
}
string BinDec(long long x) {
  string z;
  while (1) {
    if (x % 2 == 0)
      z += '0';
    else
      z += '1';
    x /= 2;
    if (x == 0) break;
  }
  reverse(z.begin(), z.end());
  return z;
}
long long BinDec(string x) {
  long long i;
  unsigned long long z = 1, a = 0;
  for (i = x.size() - 1; i >= 0; i--) {
    if (x[i] == '1') a += z;
    z *= 2;
  }
  return a;
}
unsigned long long StringInt(string x) {
  unsigned long long z = 0, i;
  for (i = 0; i < x.size(); i++) {
    z *= 10;
    z += (x[i] - '0');
  }
  return z;
}
string StringInt(long long x) {
  string z;
  while (x != 0) {
    z += (x % 10 + '0');
    x /= 10;
  }
  reverse(z.begin(), z.end());
  return z;
}
unsigned long long POWMOD(unsigned long long base, unsigned long long exp,
                          unsigned long long mod) {
  unsigned long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base);
    res %= mod;
    exp /= 2;
    base = (base * base);
    base %= mod;
  }
  return res % mod;
}
unsigned long long POWE(long long base, long long exp) {
  unsigned long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base);
    exp /= 2;
    base = (base * base);
  }
  return res;
}
