#include <bits/stdc++.h>
using namespace std;
const int seed = 131;
const int maxn = 2e5 + 5;
const int mod = 998244353;
int n;
long long a[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  long long ans = n;
  long long sum = 1;
  long long now = a[1];
  for (int i = 2; i <= n; i++) {
    if (a[i] == now)
      sum++;
    else {
      ans += sum * (sum - 1) / 2;
      sum = 1;
      now = a[i];
    }
  }
  ans += sum * (sum - 1) / 2;
  printf("%I64d\n", ans);
  return 0;
}
