#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 1000LL;
long long n;
int main() {
  ios_base::sync_with_stdio(false);
  long long in, last = maxn + 123987LL, cnt = 0LL;
  long long ans = 0LL;
  cin >> n;
  for (long long i = 1LL; i <= n; i++) {
    cin >> in;
    if (last == maxn + 123987LL)
      last = in, cnt = 1LL;
    else if (last != in) {
      last = in;
      ans += (cnt * (cnt - 1)) / 2LL + cnt;
      cnt = 1LL;
    } else
      cnt++;
  }
  ans += (cnt * (cnt - 1LL)) / 2LL + cnt;
  cout << ans << endl;
}
