#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, t, cur = 1, pre, s;
  cin >> n >> pre;
  s = n;
  n--;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> t;
    if (t == pre)
      cur++;
    else if (t != pre && cur > 1) {
      s += (cur * (cur - 1) / 2);
      cur = 1;
    }
    pre = t;
  }
  if (cur > 1) s += (cur * (cur - 1) / 2);
  cout << s;
}
