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