#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long count = 1;
  long long ans = 0;
  long long num;
  scanf("%I64d", &num);
  long long prev = num;
  for (int i = 1; i < n; i++) {
    scanf("%I64d", &num);
    if (num != prev) {
      ans += (count * (count + 1) / 2);
      count = 1;
      prev = num;
    } else
      count++;
  }
  ans += count * (count + 1) / 2;
  cout << ans << endl;
  return 0;
}
