#include <bits/stdc++.h>
using namespace std;
long long f(int cnt) { return ((long long)cnt * (cnt + 1) >> 1); }
int main() {
  int n, a;
  cin >> n >> a;
  int cnt = 1;
  long long res = 0;
  for (int i = 1, prev; i < n; i++) {
    prev = a;
    cin >> a;
    if (a != prev) {
      res += f(cnt);
      cnt = 0;
    }
    cnt++;
  }
  res += f(cnt);
  cout << res;
exit:
  return (0);
}
