#include <bits/stdc++.h>
using namespace std;
std::vector<int> v;
pair<int, int> m[2][5001];
int cdad[5001][5001];
int res[5001];
int main() {
  int n, tmp;
  cin >> n;
  v.reserve(n);
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    v.push_back(tmp);
    m[0][i] = make_pair(1, tmp);
    res[tmp]++;
    cdad[i][tmp]++;
  }
  unsigned char z = 1;
  for (int j = 1; j < n; ++j) {
    for (int h = 0; h + j < n; ++h) {
      pair<int, int> sol = m[z ^ 1][h];
      int c = v[h + j];
      cdad[h][c]++;
      int x = cdad[h][c];
      if ((x > sol.first) or (x == sol.first and c < sol.second)) {
        sol.first = x;
        sol.second = c;
      }
      m[z][h] = sol;
      res[sol.second]++;
    }
    z ^= 1;
  }
  for (int i = 1; i <= n; ++i) {
    cout << res[i] << " ";
  }
  cout << endl;
}
