#include <bits/stdc++.h>
using namespace std;
int a[100100];
int main() {
  int n, i, keep = 0;
  long long ans = 0;
  scanf("%d", &n);
  a[0] = -1e9 - 1;
  a[n + 1] = 1e9 + 1;
  for (i = 1; i <= n + 1; i++) {
    if (i <= n) scanf("%d", &a[i]);
    if (a[i] != a[i - 1]) {
      if (i != 1) ans += (long long)(i - keep) * (i - keep + 1) / 2;
      keep = i;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
