#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const long long MX = 1e9;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, arr[N];
  cin >> n;
  long long ans = n, cnt = 1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (i) {
      if (arr[i] == arr[i - 1]) {
        cnt++;
      } else {
        ans += (cnt * (cnt - 1) / 2);
        cnt = 1;
      }
    }
  }
  cout << ans + (cnt * (cnt - 1) / 2) << '\n';
  return 0;
}
