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