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