#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long i = 0, j = 0, ans = 0;
  while (i < n && j < n) {
    while (j < n && v[j] == v[i]) j++;
    ans += (j - i) * (j - i + 1) / 2;
    i = j;
  }
  cout << ans;
}
