#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:100000000")
int a[100500];
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%d", &a[i]);
  long long cur = 1;
  long long ans = 0;
  for (i = 1; i < n; ++i) {
    if (a[i] == a[i - 1]) {
      cur++;
    } else {
      ans += (cur + 1) * cur / 2;
      cur = 1;
    }
  }
  ans += (cur + 1) * cur / 2;
  printf("%I64d\n", ans);
  return 0;
}
