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