#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int l[n];
  for (int i = 0; i < n; i++) cin >> l[i];
  unsigned long long int c = 0, t = 1;
  for (int i = 1; i < n; i++) {
    if (l[i] == l[i - 1])
      t += 1;
    else {
      c += (t * (t + 1)) / 2;
      t = 1;
    }
  }
  c += (t * (t + 1)) / 2;
  cout << c << "\n";
}
