#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int a[100100];
int main() {
  long long ans = 0;
  int n;
  cin >> n;
  for (int i = 0; i < int(n); i++) scanf("%d", &a[i]);
  for (int i = 0; i < n;) {
    int j = i;
    for (; j < n && a[i] == a[j]; j++)
      ;
    int k = j - i;
    ans += (1ll * k * (k - 1)) / 2 + 1ll * k;
    i = j;
  }
  cout << ans;
  return 0;
}
