#include <bits/stdc++.h>
using namespace std;
int n;
int a[100500];
int main() {
  ios ::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  a[n] = 1e9 + 1;
  long long sum = 0;
  long long cnt = 0;
  int last = 1e9 + 1;
  for (int i = 0; i < n + 1; i++) {
    if (a[i] == last)
      cnt++;
    else {
      sum += cnt * (cnt + 1) / 2;
      cnt = 1;
      last = a[i];
    }
  }
  cout << sum;
};
