#include <bits/stdc++.h>
using namespace std;
long long foo(long long c) { return (c + 1) * c / 2; }
int main() {
  long long ct, ps;
  int n, pv;
  cin >> n >> pv;
  ct = 1;
  ps = 0;
  for (int i = 1; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp != pv) {
      pv = tmp;
      ps += foo(ct);
      ct = 1;
    } else {
      ct += 1;
    }
  }
  ps += foo(ct);
  cout << ps;
  return 0;
}
