#include <bits/stdc++.h>
using namespace std;
int arr[1000000];
int main() {
  long long x, co = 0, m = 0, sum = 0, n = 1, a = 0;
  cin >> x;
  for (int i = 0; i < x; i++) {
    cin >> arr[i];
  }
  sum = x;
  for (int i = 0; i < x - 1; i++) {
    if (arr[i] == arr[i + 1]) {
      m = 1;
      co++;
    } else if (m == 1) {
      co++;
      m = 0;
      sum = sum + ((co * (co - 1)) / 2);
      co = 0;
    }
    if (m == 1 && (i == (x - 2))) {
      co++;
      sum = sum + ((co * (co - 1)) / 2);
    }
  }
  cout << sum;
  return 0;
}
