#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n;
  long long ans = 0;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (i != 0) {
      if (x == v[v.size() - 1].first)
        v[v.size() - 1].second++;
      else
        v.push_back({x, 1});
    } else {
      v.push_back({x, 1});
    }
  }
  for (auto i : v) {
    long long u = i.second;
    ans += (long long)(u * (u + 1)) / 2;
  }
  cout << ans << '\n';
  return 0;
}
