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