#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000 * 100 + 10;
long long a[MAX_N];
vector<pair<long long, long long> > v;
int main() {
  long long n, tedad = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long x = a[0], y = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] != x) {
      v.push_back(make_pair(y, i - 1));
      y = i;
      x = a[i];
    }
  }
  v.push_back(make_pair(y, n - 1));
  for (int i = 0; i < (int)v.size(); i++) {
    long long x = v[i].first, y = v[i].second, z;
    z = y - x + 1;
    tedad = tedad + z + ((z * (z - 1)) / 2);
  }
  cout << tedad << endl;
  return 0;
}
