#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
  int N;
  long long ans;
  while (cin >> N) {
    int i;
    ans = 0;
    for (i = 0; i < N; i++) scanf("%d", &a[i]);
    int t = a[0];
    int l = 1;
    for (i = 1; i < N; i++)
      if (a[i] == t) {
        l++;
      } else {
        t = a[i];
        if (l > 1) ans += ((long long)l * (l - 1)) / 2;
        l = 1;
      }
    if (l > 1) ans += ((long long)l * (l - 1)) / 2;
    printf("%I64d\n", ans + N);
  }
  return 0;
}
