#include <bits/stdc++.h>
using namespace std;
int a[100100];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int i = 0;
  long long sum = 0;
  while (i < n) {
    int j = i + 1;
    while (j < n && a[j] == a[i]) j++;
    long long num = (j - i);
    sum += (num * (num + 1)) / 2;
    i = j;
  }
  cout << sum << endl;
  return 0;
}
