#include <bits/stdc++.h>
using namespace std;
long long unsigned per(long long unsigned);
int main(int argc, char* argv[]) {
  unsigned n, col;
  long long unsigned count;
  cin >> n;
  long long int* arr = new long long int[n];
  count = n;
  col = 1;
  cin >> arr[0];
  for (unsigned i = 1; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == arr[i - 1]) {
      col++;
    } else {
      if (col == 1) {
        continue;
      }
      count += per(col);
      col = 1;
    }
  }
  if (col > 1) {
    count += per(col);
  }
  cout << count << endl;
  delete[] arr;
  return 0;
}
long long unsigned per(long long unsigned value) {
  long long unsigned rez = 0;
  value--;
  while (value) {
    rez += value;
    value--;
  }
  return rez;
}
