#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long resp = N;
  long long last;
  long long n_elements = 1LL;
  cin >> last;
  for (int i = 1; i < N; i++) {
    long long aux;
    cin >> aux;
    if (aux == last)
      resp += n_elements++;
    else
      n_elements = 1LL;
    last = aux;
  }
  cout << resp << endl;
  return 0;
}
