#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], m[6000] = {0}, ans[6000], s = 0, c = 0, i, j, d, max = 0, x;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    d = 10000;
    max = 0;
    c = 0;
    s = 0;
    for (j = 0; j < 5001; j++) {
      m[j] = 0;
    }
    for (j = i; j < n; j++) {
      if (j == i) {
        x = a[i];
        c++;
        s++;
      } else {
        if (x == a[j]) {
          c++;
          if (c > max)
            s++;
          else if (c == max) {
            if (x < d)
              s++;
            else {
              ans[d - 1]++;
            }
          } else {
            ans[d - 1]++;
          }
        } else {
          m[a[j]]++;
          if (m[a[j]] > max) {
            max = m[a[j]];
            d = a[j];
          } else if (m[a[j]] == max) {
            if (d > a[j]) {
              d = a[j];
            }
          }
          if (c > max)
            s++;
          else if (c == max) {
            if (x < d)
              s++;
            else {
              ans[d - 1]++;
            }
          } else {
            ans[d - 1]++;
          }
        }
      }
    }
    ans[a[i] - 1] += s;
  }
  for (i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
