#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n;
  scanf("%d", &n);
  int a, b;
  scanf("%d", &a);
  int num = 1;
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d", &b);
    if (b == a)
      num++;
    else {
      ans += (long long)num * (num + 1) / 2;
      a = b;
      num = 1;
    }
  }
  ans += (long long)num * (num + 1) / 2;
  cout << ans << endl;
  return 0;
}
