#include <bits/stdc++.h>
using namespace std;
int get() {
  int x;
  scanf("%d", &x);
  return x;
}
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  long long cnt = 0, t = 1;
  for (int i = 1; i < n; ++i) {
    if (arr[i] == arr[i - 1]) {
      t++;
    } else {
      cnt += (t * (t - 1)) >> 1;
      t = 1;
    }
  }
  cnt += (t * (t - 1)) >> 1;
  cout << cnt + n << '\n';
  return 0;
}
