#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  int prev;
  int cnt;
  for (int i = 0; i < n; i++) {
    if (i && a[i] == prev)
      cnt++;
    else
      cnt = 1;
    prev = a[i];
    ans += cnt;
  }
  cout << ans;
  return 0;
}
