#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, shet = 0;
  long long int ans = 0;
  cin >> n;
  ans = n;
  int* mas = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> mas[i];
  }
  for (int i = 1; i < n; i++) {
    if (mas[i] == mas[i - 1]) {
      shet++;
      ans += shet;
    } else {
      shet = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
