#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long a[N];
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int t = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      if (t > 1) ans += ((long long)t * (t - 1)) / 2;
      t = 1;
    } else {
      t++;
    }
  }
  if (t > 1) ans += ((long long)t * (t - 1)) / 2;
  ans += n;
  cout << ans << endl;
  return 0;
}
