#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, n, p, c = 1;
  cin >> N;
  --N;
  long long res = 1;
  cin >> p;
  while (N--) {
    cin >> n;
    if (p == n)
      ++c;
    else
      c = 1;
    res += c;
    p = n;
  }
  cout << res;
}
