#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9 + 7;
const int N = (int)1e5 + 5;
int a[N];
int main() {
  int n;
  scanf("%d", &n);
  long long ans = n;
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  long long cnt = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1])
      ++cnt;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  printf("%lld", ans);
  cin.ignore();
  cin.get();
}
