#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long ans = 0;
  long long len = 0;
  for (int i = 1; i <= n; i++) {
    len = 0;
    int j;
    for (j = i; j <= n; j++) {
      if (a[i] == a[j])
        len++;
      else
        break;
    }
    i = j - 1;
    ans += len * (len + 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
