#include <bits/stdc++.h>
using namespace std;
int n;
int a[100002];
long long solve() {
  int t = a[0];
  long long ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == t)
      cnt++;
    else {
      if (cnt == 1)
        ans += 1;
      else
        ans += (long long)cnt * (cnt - 1) / 2 + (long long)cnt;
      if (i != n - 1) t = a[i];
      cnt = 1;
    }
  }
  if (cnt) {
    if (cnt == 1)
      ans += 1;
    else
      ans += (long long)cnt * (cnt - 1) / 2 + (long long)cnt;
  }
  return ans;
}
inline int Rint() {
  int x;
  scanf("%d", &x);
  return x;
}
int main() {
  n = Rint();
  for (int i = 0; i < n; i++) a[i] = Rint();
  printf("%I64d\n", solve());
}
