#include <bits/stdc++.h>
using namespace std;
long long int a[5006], b[5006];
pair<int, int> dp[5006][5006];
int main() {
  long long n, m, x, y, e, r, k, sum;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(b, 0, sizeof b);
  for (int i = 1; i <= n; i++) {
    sum = 1;
    dp[i][i].first = 1;
    dp[i][i].second = a[i];
    b[a[i]]++;
    for (int j = i - 1; j >= 1; j--) {
      if (a[j] == a[i]) sum++;
      if (dp[j][i - 1].first < sum) {
        dp[j][i].first = sum;
        dp[j][i].second = a[i];
        b[a[i]]++;
      } else if (dp[j][i - 1].first > sum) {
        dp[j][i].first = dp[j][i - 1].first;
        dp[j][i].second = dp[j][i - 1].second;
        b[dp[j][i].second]++;
      } else if (dp[j][i - 1].first == sum && dp[j][i - 1].second < a[i]) {
        dp[j][i].first = dp[j][i - 1].first;
        dp[j][i].second = dp[j][i - 1].second;
        b[dp[j][i - 1].second]++;
      } else if (dp[j][i - 1].first == sum && dp[j][i - 1].second > a[i]) {
        dp[j][i].first = sum;
        dp[j][i].second = a[i];
        b[a[i]]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << b[i] << " ";
  }
}
