#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long a[200000], i, last, first, n, s, k;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  s = n;
  for (i = 1; i <= n; i++) {
    if (i == 1 || a[i] != a[i - 1]) first = i;
    if (i == n || a[i] != a[i + 1]) {
      last = i;
      k = last - first;
      s += k * (k + 1) / 2;
    }
  }
  cout << s;
}
