#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  long long c = n, maxi = INT_MIN, mini = INT_MIN, t = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (maxi != a[i]) {
      maxi = a[i];
      mini = a[i];
      t = 1;
    } else {
      t++;
      c += t - 1;
    }
  }
  cout << c << endl;
  return 0;
}
