#include <bits/stdc++.h>
using namespace std;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
const double phi = acos(-1);
int main() {
  long long n, a[100005], sum = 0, cnt = 1;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[1] == 0) a[0] = 1;
    if (a[i] == a[i - 1]) {
      sum += cnt;
      cnt++;
    } else
      cnt = 1;
  }
  n = n + sum;
  cout << n << '\n';
  return 0;
}
