#include <bits/stdc++.h>
using namespace std;
void solve(vector<long long>& a, int n) {
  long long sum = 0LL;
  for (long long i = 0; i < a.size(); i++) {
    if (i < n - 1 && a[i] == a[i + 1]) {
      long long j;
      for (j = i; j < a.size() - 1; j++) {
        if (a[j] == a[j + 1])
          continue;
        else
          break;
      }
      sum += ((long long)(j - i + 1) * (long long)(j - i + 2)) / 2;
      i = j;
    } else
      sum++;
  }
  cout << sum << endl;
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(a, n);
  return 0;
}
