#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, k, i, j, x, r, m, y, d, q, l, p, g, b, ct, ans;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  ct = 0;
  ans = 0;
  for (i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1])
      ct++;
    else {
      ct++;
      ans = ans + (ct * (ct + 1)) / 2;
      ct = 0;
    }
  }
  ct++;
  ans = ans + (ct * (ct + 1)) / 2;
  cout << ans;
  return 0;
}
