#include <bits/stdc++.h>
using namespace std;
void swap(int &a, int &b) {
  int temp;
  temp = a;
  a = b;
  b = temp;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long int a[n];
  ;
  for (long int i = 0; i < n; i++) cin >> a[i];
  long long int s = 0;
  long long int x = a[0];
  long long int count = 1;
  ;
  for (long int i = 1; i < n; i++) {
    if (a[i] == x)
      count++;
    else {
      s = s + (count * (count + 1)) / 2;
      x = a[i];
      count = 1;
    }
  }
  s = s + (count * (count + 1)) / 2;
  cout << s;
  return 0;
}
