#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int firstdata, seconddata, saved = 0;
  long long int result = n;
  cin >> firstdata;
  for (long long int i = 0; i < n - 1; i++) {
    cin >> seconddata;
    if (firstdata != seconddata) {
      saved = 0;
      firstdata = seconddata;
      continue;
    } else {
      saved++;
      result += saved;
      firstdata = seconddata;
    }
  }
  cout << result << endl;
}
