#include <bits/stdc++.h>
using namespace std;
int arr[5005], ans[5005];
int fre[5005][5005], dp[5005][5005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  memset(fre, 0, sizeof fre);
  fre[0][arr[0]]++;
  for (int i = 1; i < n; i++) {
    fre[i][arr[i]]++;
    for (int j = 1; j <= n; j++) fre[i][j] += fre[i - 1][j];
  }
  for (int i = 0; i < n; i++) dp[i][i] = arr[i];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int maxi;
      if (i != 0)
        maxi = fre[j][dp[i][j - 1]] - fre[i - 1][dp[i][j - 1]];
      else
        maxi = fre[j][dp[i][j - 1]];
      int nmaxi;
      if (i != 0)
        nmaxi = fre[j][arr[j]] - fre[i - 1][arr[j]];
      else
        nmaxi = fre[j][arr[j]];
      if (nmaxi > maxi)
        dp[i][j] = arr[j];
      else if (nmaxi < maxi)
        dp[i][j] = dp[i][j - 1];
      else
        dp[i][j] = min(dp[i][j - 1], arr[j]);
    }
  }
  memset(ans, 0, sizeof ans);
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) ans[dp[i][j]]++;
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}
