#include <bits/stdc++.h>
using namespace std;
long long ans;
int seq[1234567], n;
long long nc2(long long x) { return (x * (x + 1LL)) / 2LL; }
int main() {
  cin >> n;
  for (int i = (0); i < (n); i++) {
    cin >> seq[i];
  }
  int i = 0;
  ans = 0;
  while (i < n) {
    int i1 = i + 1;
    while (i1 < n && seq[i1] == seq[i]) i1++;
    ans += nc2(i1 - i);
    i = i1;
  }
  cout << ans << endl;
  return 0;
}
