#include <bits/stdc++.h>
int a[100010];
int n;
long long int answer;
int main(void) {
  int i, p;
  long long int v;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  a[n + 1] = 2147483647;
  for (i = 1; i <= n; i++) {
    p = i;
    for (; i <= n; i++) {
      if (a[i] != a[i + 1]) break;
    }
    v = (long long int)(i - p + 1);
    answer += (v * (v - 1)) / 2;
  }
  answer += (long long int)n;
  printf("%I64d\n", answer);
  return false;
}
