#include <bits/stdc++.h>
using namespace std;
int main() {
  const int INF = 1000000005;
  int n;
  while (scanf("%d", &n) != EOF) {
    vector<int> v(n + 1, 0);
    for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
    v[n] = INF;
    long long res = n;
    for (int i = 0; i < n;) {
      long long j = i + 1;
      while (v[j] == v[i]) ++j;
      j = j - i;
      res += ((j * (j - 1)) / 2);
      i += j;
    }
    cout << res << endl;
  }
  return 0;
}
