#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, o, c;
  long long r = 0, k = 1;
  cin >> n;
  cin >> c;
  for (int i = 1; i < n; i++) {
    o = c;
    cin >> c;
    if (o != c) {
      r += k * (k + 1) / 2;
      k = 1;
    } else
      k++;
  }
  r += k * (k + 1) / 2;
  cout << r;
exit:
  return (0);
}
