#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int n;
  cin >> n;
  long long int a[n], i, z, c;
  for (i = 0; i < n; i++) cin >> a[i];
  c = 1;
  z = 0;
  a[n] = 1000000000000;
  for (i = 0; i < n; i++) {
    if (a[i] == a[i + 1])
      c++;
    else {
      if (c > 1) {
        z = z + (c * (c - 1)) / 2;
        c = 1;
      }
    }
  }
  cout << z + n;
}
