#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int value;
  int last = 1e9 + 1;
  long long ans = 0, count = 0L;
  for (int i = 0; i < n; ++i) {
    cin >> value;
    if (value != last) {
      if (count > 0L) {
        if (count & 1) {
          ans += (count + 1) / 2 * count;
        } else {
          ans += count / 2 * (count + 1);
        }
      }
      last = value;
      count = 1L;
    } else {
      ++count;
    }
  }
  if (count & 1) {
    ans += (count + 1) / 2 * count;
  } else {
    ans += count / 2 * (count + 1);
  }
  cout << ans << endl;
  return 0;
}
