#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, co = 0, com, a;
  long long int ans = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (i == 0) com = a;
    if (a == com) {
      co++;
    } else {
      com = a;
      ans = ans + (co * (co - 1) / 2);
      co = 1;
    }
  }
  ans = ans + (co * (co - 1) / 2);
  printf("%lld\n", ans + n);
  return 0;
}
