#include <bits/stdc++.h>
using namespace std;
unsigned long long int ull;
void solve() {
  int n;
  cin >> n;
  int a[n + 1];
  map<long long int, long long int> mp;
  long long int cnt = 0, c = 1;
  cin >> a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i - 1] == a[i])
      c++;
    else {
      cnt = cnt + (c * (c + 1)) / 2;
      c = 1;
    }
  }
  cnt = cnt + (c * (c + 1)) / 2;
  cout << cnt << endl;
}
int main() {
  solve();
  return 0;
}
