#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010];
long long mn = 1e9, mx = -1e9, ans, cnt, sm;
bool ok, okk, used[1000010], use[10010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cur = a[0];
  cnt = 1;
  for (int i = 1; i < n; i++) {
    if (cur == a[i]) {
      cnt++;
    } else {
      ans += cnt * (cnt - 1) / 2;
      cur = a[i];
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans + n;
  return 0;
}
