#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  cin >> n;
  long long sum = 1, c = 1;
  long long h, q;
  cin >> h;
  for (i = 0; i < n - 1; i++) {
    cin >> q;
    if (q != h) {
      sum++;
      c = 1;
    } else {
      c++;
      sum += c;
    }
    h = q;
  }
  cout << sum << endl;
}
