#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long res = 0;
  int p;
  int l = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      scanf("%d", &p);
      l = 1;
      continue;
    }
    int x;
    scanf("%d", &x);
    if (x == p) {
      l++;
      continue;
    }
    res += (long long)l * (l + 1) / 2;
    p = x;
    l = 1;
  }
  res += (long long)l * (l + 1) / 2;
  cout << res << endl;
}
