#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, number, cnt = 0, prev;
  long long res = 0;
  cin >> n;
  --n;
  cin >> prev;
  for (int i = 0; i < n; ++i) {
    cin >> number;
    if (number != prev) {
      res += (long long)(1 + cnt + 1) * (cnt + 1) / 2;
      cnt = 0;
    } else {
      ++cnt;
    }
    prev = number;
  }
  res += (long long)(1 + cnt + 1) * (cnt + 1) / 2;
  cout << res << endl;
  return 0;
}
