#include <bits/stdc++.h>
unsigned int C[5000 + 2][5000 + 2] = {{0}};
unsigned int D[5000 + 2][5000 + 2] = {{0}};
unsigned int R[5000 + 2] = {0};
static unsigned short count(int c, int i, int j) {
  return (C[j][c] - C[i - 1][c]);
}
int main(int argc, char *argv[]) {
  int n, t;
  int i, j;
  scanf("%d", &n);
  for (j = 1; j <= n && scanf("%d", &t) == 1; j++) {
    memcpy(&C[j][0], &C[j - 1][0], sizeof(C[0][0]) * (5000 + 1));
    C[j][t]++;
    for (i = j; i > 0; i--) {
      int c = D[j - 1][i], tij = count(t, i, j), cij = count(c, i, j);
      if (tij > cij || (tij == cij && t < c)) {
        D[j][i] = t;
      } else
        D[j][i] = c;
      R[D[j][i]]++;
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%u%c", (unsigned int)R[i], (i == n) ? '\n' : ' ');
  }
  return 0;
}
