#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long count = 1;
  long long now, past;
  long long sum = 0;
  cin >> n;
  cin >> past;
  for (int i = 0; i < n - 1; i++) {
    cin >> now;
    if (now == past) {
      count++;
    } else {
      past = now;
      sum += (count * (count + 1)) / 2;
      count = 1;
    }
  }
  sum += (count * (count + 1)) / 2;
  cout << sum;
  return 0;
}
