#include <bits/stdc++.h>
int main() {
  long long count = 0;
  long long int n, a[100010], j, i;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++)
      if (a[i] != a[j]) break;
    count += ((j - i - 1) * (j - i)) / 2;
    i = j - 1;
  }
  printf("%lld\n", count + n);
  return 0;
}
