#include <bits/stdc++.h>
using namespace std;
bool customSort(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first != b.first) return a.first > b.first;
  return a.second < b.second;
}
void solve() {
  long long int n, c = 1, s = 0, t = 0;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    long long int a;
    cin >> a;
    if (i == 0)
      t = a;
    else {
      if (t == a) {
        c++;
        t = a;
        if (i == n - 1) s += (c * (c - 1) / 2);
      } else {
        s += (c * (c - 1) / 2);
        c = 1;
        t = a;
      }
    }
  }
  cout << n + s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  int n = 1;
  while (n--) solve();
  return 0;
}
