#include <bits/stdc++.h>
int min(int a, int b) { return (a > b) ? b : a; }
int max(int a, int b) { return (a > b) ? a : b; }
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int a[100000] = {0};
int main() {
  int n;
  scanf("%d", &n);
  int i;
  int p = 1;
  long long total = 0;
  scanf("%d", &a[0]);
  for (i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == a[i - 1])
      p++;
    else {
      total += (long long)p * (p + 1) / 2;
      p = 1;
    }
  }
  total += (long long)p * (p + 1) / 2;
  printf("%I64d", total);
  return 0;
}
