#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
int a[1000000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (i && a[i - 1] != a[i]) {
      ans += (long long)k * (long long)(k + 1) / 2;
      k = 1;
    } else
      k++;
  }
  ans += (long long)k * (long long)(k + 1) / 2;
  cout << ans << endl;
  return 0;
}
