#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
int n;
int main() {
  cin >> n;
  long long ans = 0;
  int len = 1, a, cur;
  cin >> cur;
  for (int i = 1; i < n; ++i) {
    cin >> a;
    if (cur != a) {
      ans += 1ll * (1 + len) * len / 2;
      cur = a;
      len = 1;
    } else {
      len++;
    }
  }
  ans += 1ll * (1 + len) * len / 2;
  cout << ans << endl;
  return 0;
}
