#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &v : a) {
    cin >> v;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long x = a[i], c = 0;
    while (i < n and x == a[i]) {
      ++i;
      ++c;
    }
    --i;
    ans += (c * c + c) / 2;
  }
  cout << ans << endl;
  return 0;
}
