#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int L = 1, R = 1;
  long long ans = 0;
  while (R <= n) {
    R++;
    if (a[L] == a[R]) continue;
    int x = R - L;
    ans += (x * 1ll * (x + 1) / 2);
    L = R;
  }
  int x = R - L;
  ans += (x * 1ll * (x + 1) / 2);
  cout << ans;
  return 0;
}
