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