#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  scanf("%d", &n);
  int t[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }
  int t2[n];
  int k = 0;
  int i = 0;
  int max = 0;
  while (i < n) {
    int j = i + 1;
    int ok = 1;
    while ((j < n) && (ok)) {
      if (t[i] == t[j])
        j += 1;
      else
        ok = 0;
    }
    if ((j - i) > 1) {
      t2[k] = (j - i);
      k += 1;
      if ((j - i) > max) max = j - i;
    }
    i = j;
  }
  long long int faza[max + 1];
  faza[0] = 0;
  faza[1] = 0;
  for (int s = 2; s <= max; s++) {
    faza[s] = (long long int)(faza[s - 1] + s - 1);
  }
  long long int res = (long long int)n;
  for (int i = 0; i < k; i++) {
    res += (long long int)faza[t2[i]];
  }
  cout << res;
}
