#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> ar(n + 1, 1e10);
  vector<long long> cur(n + 1, 1);
  for (long long i = 1; i <= n; i++) {
    cin >> ar[i];
    if (ar[i] == ar[i - 1]) cur[i] = cur[i - 1] + 1;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) ans += cur[i];
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) solve();
  return 0;
}
