#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 60;
long long n, ans;
int main() {
  cin >> n;
  long long pre = inf, num = 0, sum = 0;
  ans = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a != pre) {
      ans += sum;
      num = 0;
      pre = a;
      sum = 0;
    }
    sum += num + 1;
    num++;
  }
  cout << ans + sum << endl;
}
