#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int len = 0, x, pre;
  long long ans = 0LL;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (i != 0) {
      if (pre == x) {
        len++;
      } else {
        ans += 1LL * (len + 1) * len / 2;
        len = 1;
      }
    } else
      len = 1;
    pre = x;
  }
  ans += 1LL * (len + 1) * len / 2;
  cout << ans << '\n';
  return 0;
}
