#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n], i;
  for (i = 0; i < n; ++i) cin >> a[i];
  long long int cnt = 0, sum = n;
  for (i = 0; i < n - 1; ++i) {
    if (a[i] == a[i + 1])
      cnt++;
    else {
      cnt = cnt + 1;
      sum += (cnt * (cnt - 1)) / 2;
      cnt = 0;
    }
  }
  cnt = cnt + 1;
  sum += (cnt * (cnt - 1)) / 2;
  cout << sum;
  return 0;
}
