#include <bits/stdc++.h>
using namespace std;
int n, a, curr;
vector<long long int> v;
void start() {
  cin >> n;
  int times = 0;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i == 0) {
      curr = a;
      times++;
      if (i == n - 1) v.push_back(times);
      continue;
    } else if (curr != a) {
      v.push_back(times);
      times = 1;
      if (i == n - 1) v.push_back(times);
      curr = a;
    } else {
      times++;
      if (i == n - 1) v.push_back(times);
    }
  }
  long long int sol = 0;
  for (int i = 0; i < v.size(); i++) {
    long long int t = v[i];
    sol += (t * (t + 1)) / 2;
  }
  cout << sol << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  start();
  return 0;
}
