#include <bits/stdc++.h>
using namespace std;
long long abs(long long, long long);
void solve() {
  long long n;
  cin >> n;
  long long a[n], ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long t = 1;
  for (long long i = 0; i < n; i++) {
    if (i == n - 1) {
      ans++;
    } else {
      if (a[i] == a[i + 1]) {
        if (i == n - 2) {
          t++;
          ans += (t * (t + 1)) / 2;
          break;
        }
        t++;
      } else {
        ans += (t * (t + 1)) / 2;
        t = 1;
      }
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
long long abs(long long a, long long b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
