#include <bits/stdc++.h>
using namespace std;
int main() {
  long j, i, n, a[200001];
  long long c, ans = 0;
  scanf("%I32d", &n);
  for (i = 0; i < n; i++) scanf("%I32d", &a[i]);
  i = 0;
  while (i < n) {
    j = i;
    while ((j < n) && (a[i] == a[j])) j++;
    c = j - i;
    ans += c * (c + 1) / 2;
    i = j;
  }
  printf("%I64d", ans);
  return 0;
}
