#include <bits/stdc++.h>
using namespace std;
long long aa[1000005];
int n;
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) cin >> aa[i];
    long long sum = 0;
    for (int l = 0; l < n;) {
      int r;
      for (r = l; r < n - 1 && aa[r + 1] == aa[l]; r++)
        ;
      sum += (long long)(r - l + 1) * (r - l + 2) / 2;
      l = r + 1;
    }
    cout << sum << endl;
  }
  return 0;
}
