#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long n, sum = 0, tmp = 1;
  cin >> n;
  long long arr[100000];
  for (int x = 0; x < n; cin >> arr[x++])
    ;
  for (int x = 0; x < n; x++) {
    if (arr[x] == arr[x + 1] && x != n - 1)
      tmp++;
    else {
      while (3) {
        sum += tmp;
        tmp--;
        if (tmp == 0) break;
      }
      tmp = 1;
    }
  }
  cout << sum;
  return 0;
}
