#include <bits/stdc++.h>
using namespace std;
int ans[5005];
int a[5005];
int cnt[5005][5005];
int mx, freq;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i) {
      for (int j = 1; j <= n; j++) {
        if (j != a[i]) cnt[j][i] = cnt[j][i - 1];
      }
      cnt[a[i]][i] += cnt[a[i]][i - 1] + 1;
    } else
      cnt[a[i]][i]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (j == i) {
        ans[a[j]]++;
        mx = a[j];
        freq = 1;
      } else {
        if (cnt[a[j]][j] - cnt[a[j]][i - 1] == freq) {
          if (a[j] < mx) {
            mx = a[j];
            ans[a[j]]++;
          } else {
            ans[mx]++;
          }
        } else if (cnt[a[j]][j] - cnt[a[j]][i - 1] > freq) {
          mx = a[j];
          freq = cnt[a[j]][j] - cnt[a[j]][i - 1];
          ans[a[j]]++;
        } else {
          ans[mx]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
