#include <bits/stdc++.h>
using namespace std;
int dp[5005][5005], ele[5005][5005], occ[5005];
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 5];
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (a[j] == i) {
        ele[i][j] = ele[i][j - 1] + 1;
      } else
        ele[i][j] = ele[i][j - 1];
    }
  }
  for (int i = 1; i <= n; ++i) {
    dp[i][i] = a[i];
    occ[a[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int ax = dp[i][j - 1];
      int is = a[j];
      int ois = ele[is][j] - ele[is][i - 1];
      int oax = ele[ax][j] - ele[ax][i - 1];
      if (ois > oax)
        dp[i][j] = is;
      else if (oax > ois)
        dp[i][j] = ax;
      else
        dp[i][j] = min(ax, is);
      occ[dp[i][j]]++;
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d ", occ[i]);
  return 0;
}
