#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, tgt, ans = 0, now, cnt = 0;
  cin >> n;
  for (unsigned long long i = 0; i < ((unsigned long long)n); i++) {
    cin >> tgt;
    if (tgt == now || i == 0) {
      cnt++;
    } else {
      ans += cnt * (cnt + 1) / 2;
      cnt = 1;
    }
    now = tgt;
  }
  ans += cnt * (cnt + 1) / 2;
  cout << ans << endl;
  return 0;
}
