#include <bits/stdc++.h>
using namespace std;
int n, m;
long long C[100005];
unsigned long long sol;
int main() {
  sol = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> C[i];
  long long last = C[0], cont = 1;
  for (int i = 1; i < n; i++)
    if (C[i] != last) {
      sol += (cont * (cont + 1)) / 2;
      cont = 1;
      last = C[i];
    } else
      cont++;
  sol += cont * (cont + 1) / 2;
  cout << sol << endl;
  return 0;
}
