#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    long long ans = 0;
    int last, nn = 1;
    scanf("%d", &last);
    for (int i = 1; i < n; i++) {
      int t;
      scanf("%d", &t);
      if (last == t)
        nn++;
      else {
        ans += ((long long)nn * (nn + 1) / 2);
        nn = 1;
      }
      last = t;
    }
    ans += ((long long)nn * (nn + 1) / 2);
    cout << ans << endl;
  }
  return 0;
}
