#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const long long INF = 1000000000000000000;
const char *in_file = "input.txt";
const char *out_file = "output.txt";
int n, m;
int main() {
  cin >> n;
  vector<int> v(n), d(n, 1);
  for (int _n(n), i(0); i < _n; i++) cin >> v[i];
  long long res = 0;
  for (int _n(n), i(1); i < _n; i++)
    if (v[i - 1] == v[i]) {
      d[i] = d[i - 1] + 1;
      d[i - 1] = 0;
    }
  for (int _n(n), i(0); i < _n; i++) res += (((long long)d[i] + 1) * d[i]) / 2;
  cout << res << endl;
}
