#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;
const int N = 1e5 + 5, inf = 1e18;
int arr[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  ll ans = n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  ll x = arr[0], cnt = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] == x)
      cnt++;
    else {
      ans += (cnt * (cnt - 1)) / 2;
      x = arr[i], cnt = 1;
    }
  }
  ans += (cnt * (cnt - 1)) / 2;
  cout << ans << "\n";
  return 0;
}
