#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a, b, cntr = 1;
  long long ans = 1;
  cin >> N >> b;
  while (--N) {
    cin >> a;
    if (a == b)
      cntr++;
    else
      cntr = 1;
    ans += cntr;
    b = a;
  }
  cout << ans;
  return 0;
}
