#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int ans = n;
  for (int i = 0; i < n;) {
    long long int cnt = 0;
    long long int temp = a[i];
    while (i < n and temp == a[i]) {
      cnt++;
      i++;
    }
    ans += ((cnt) * (cnt - 1) / 2);
  }
  cout << ans << endl;
}
