#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, cnt = 0;
  long long sum = 0;
  cin >> n;
  set<int> s;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int l = 0, r = 0;
  while (l < n) {
    while (r < n && arr[r] == arr[l]) {
      cnt++;
      r++;
    }
    sum += (cnt * (cnt + 1) / 2);
    cnt = 0;
    l = r;
  }
  cout << sum;
  return 0;
}
