#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long I, N, pre, cur, cnt = 0, res;
  cin >> N;
  res = N;
  for (I = 1; I <= N; I = I + 1) {
    cin >> cur;
    if (I != 1 && pre == cur) {
      if (cnt == 0) cnt = 1;
      cnt = cnt + 1;
      if (I == N) res = res + (cnt * (cnt - 1) / 2);
    } else {
      res = res + (cnt * (cnt - 1) / 2);
      cnt = 0;
    }
    pre = cur;
  }
  cout << res << "\n";
  return 0;
}
