#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int lst, x;
  long long ret, cnt;
  while (cin >> n) {
    cin >> lst;
    cnt = 1, ret = 0;
    for (int i = 0; i < n - 1; i++) {
      cin >> x;
      if (x == lst)
        cnt++;
      else
        ret += cnt * (cnt + 1) / 2, lst = x, cnt = 1;
    }
    ret += cnt * (cnt + 1) / 2;
    cout << ret << endl;
  }
  return 0;
}
