#include <bits/stdc++.h>
using namespace std;
long long niz[1000011];
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> niz[i];
  long long out = 0;
  for (long long i = 0; i < n;) {
    long long siz = 0, curr = niz[i];
    while (niz[i] == curr) {
      siz++;
      i++;
      if (i == n) break;
    }
    out += siz * (siz + 1) / 2;
  }
  cout << out << endl;
}
