#include <bits/stdc++.h>
using namespace std;
int a[100009];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  long long res = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && a[j] == a[i]) j++;
    long long sz = j - i;
    res += sz * (sz + 1) / 2;
    i = j;
  }
  cout << res << endl;
}
