#include <bits/stdc++.h>
using namespace std;
long long how(int n) {
  long long c = 0;
  for (int i = 1; i <= n; i++) c += i;
  return c;
}
int main() {
  int n, mas[100000];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> mas[i];
  int temp = 0;
  long long sum = n;
  for (int i = 1; i < n; i++) {
    if (mas[i] == mas[i - 1])
      temp++;
    else {
      sum += how(temp);
      temp = 0;
    }
  }
  sum += how(temp);
  cout << sum;
  return 0;
}
