#include <bits/stdc++.h>
using namespace std;
long long a[1000000];
long long res = 0;
int main() {
  long long n, i, j, k, l, s;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  j = 1;
  a[n] = a[n - 1] + 1;
  for (i = 1; i <= n; i++) {
    if (a[i] == a[i - 1])
      j++;
    else {
      res += j * (j + 1) / 2;
      j = 1;
    }
  }
  cout << res;
}
