#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> arr(n);
  for (int i = 0; i < (n); i++) cin >> arr[i];
  long long ans = 0, t = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1])
      t++;
    else {
      ans += (t) * (t + 1) / 2;
      t = 1;
    }
  }
  ans += t * (t + 1) / 2;
  cout << ans << endl;
  return 0;
}
