#include <bits/stdc++.h>
using namespace std;
int c[5001][5001];
int co[5001];
int x[5001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) c[0][i] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    for (int j = 1; j <= n; j++) {
      if (x[i] == j)
        c[i][j] = c[i - 1][j] + 1;
      else
        c[i][j] = c[i - 1][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    co[x[i]] = co[x[i]] + 1;
    int d = 1;
    int f = x[i];
    for (int j = i + 1; j <= n; j++) {
      int h = c[j][x[j]] - c[i - 1][x[j]];
      if (x[j] != f) {
        if (h > d) {
          co[x[j]] = co[x[j]] + 1;
          f = x[j];
          d = h;
        } else {
          if (h == d) {
            if (f > x[j]) {
              co[x[j]] = co[x[j]] + 1;
              f = x[j];
              d = h;
            } else {
              co[f] = co[f] + 1;
            }
          } else
            co[f]++;
        }
      } else {
        co[f] = co[f] + 1;
        d++;
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << co[i] << " ";
  cout << endl;
}
