#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
  ll n;
  cin >> n;
  vector<ll> nums(n);
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
  }
  ll ans = 0;
  ll s = 0, e = 0;
  ll curr = 0;
  while (e < n) {
    if (nums[s] == nums[e]) {
      e++;
      curr++;
    } else {
      ans += (curr * (curr + 1)) / 2;
      curr = 0;
      s = e;
    }
  }
  ans += (curr * (curr + 1)) / 2;
  cout << ans << "\n";
  return 0;
}
