#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int siz(const T& c) {
  return (int)c.size();
}
int main() {
  long long n, l, r;
  vector<long long> data;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> l;
    data.push_back(l);
  }
  r = 0;
  l = 1;
  long long c = data[0];
  int i = 1;
  while (i < siz(data)) {
    if (data[i] == c) {
      l++;
      i++;
    } else {
      r += (l + 1) * l / 2;
      l = 1;
      c = data[i];
      i++;
    }
  }
  r += (l + 1) * l / 2;
  cout << r;
  exit(0);
}
