#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, s = 0, pr = 99999999, m, c = 0;
  vector<long long> v;
  cin >> n;
  while (n--) {
    cin >> m;
    if (m == pr)
      c++;
    else
      c = 1;
    s += c;
    pr = m;
  }
  cout << s;
}
