#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    v.push_back(a);
  }
  vector<long long> cnt;
  cnt.push_back(1);
  for (int i = 1; i < n; ++i) {
    if (v[i] == v[i - 1]) {
      cnt[cnt.size() - 1]++;
    } else {
      cnt.push_back(1);
    }
  }
  long long sum = 0;
  for (int i = 0; i < cnt.size(); ++i) {
    sum += (cnt[i] * (cnt[i] + 1)) / 2;
  }
  cout << sum << endl;
  return 0;
}
