#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, s, k = 0;
  cin >> n;
  long long int a[n];
  i = 0;
  while (i < n) {
    cin >> a[i];
    i++;
  }
  s = n;
  for (i = 1; i < n; i++) {
    if (a[i] == a[i - 1])
      s += i - k;
    else
      k = i;
  }
  cout << s;
  return 0;
}
