#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, n, a, b, c, m, x, y, z, num,
      count = 0, count1 = 0, count2 = 0, sum = 0, sum1 = 0, sum2 = 0, check = 0,
      len = 0, small = 0, big = 0;
  string str, str1, str2;
  cin >> n;
  int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  for (i = 0; i < n; i++) {
    count = 0;
    while (arr[i] == arr[i + 1] && i < n - 1) {
      count++;
      i++;
    }
    count++;
    sum += (count * (count - 1)) / 2;
  }
  sum += n;
  cout << sum;
  return 0;
}
