#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = (int)1e9;
const long long int prime = 31;
bool w1(false);
string a[3];
bool win(char c) {
  for (int i = 0; i < 3; ++i) {
    if (a[i][0] == c && a[i][1] == c && a[i][2] == c) return true;
    if (a[0][i] == c && a[1][i] == c && a[2][i] == c) return true;
  }
  if (a[0][0] == c && a[1][1] == c && a[2][2] == c) return true;
  if (a[0][2] == c && a[1][1] == c && a[2][0] == c) return true;
  return false;
}
int main() {
  int n;
  cin >> n;
  int k;
  long long int count = 0;
  long long int buf = 0;
  long long int total = 0;
  for (int i = 0; i < n; ++i) {
    cin >> k;
    if (count == 0) {
      buf = k;
      count = 1;
    } else if (k == buf) {
      count++;
    } else {
      total += count * (count + 1) / 2;
      count = 1;
      buf = k;
    }
  }
  total += count * (count + 1) / 2;
  cout << total;
  return 0;
}
