#include <bits/stdc++.h>
unsigned long long getSum(unsigned long long n) { return (n * (n + 1)) / 2; }
int main(void) {
  int n = 0, i = 0;
  int *p = 0, num = 0;
  int arr[100001] = {
      0,
  };
  unsigned long long cnt = 0;
  unsigned long long sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  sum = n;
  p = arr;
  while (p < arr + n) {
    num = *p;
    cnt = 0;
    while (p < arr + n && *p == num) {
      p++;
      cnt++;
    }
    sum += getSum(cnt - 1);
  }
  printf("%llu\n", sum);
  return 0;
}
