#include <bits/stdc++.h>
using namespace std;
long long n, a[100010];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    unsigned long long j, k = 0;
    for (j = i; j < n; j++) {
      if (a[i] != a[j]) break;
      k++;
    }
    ans += (k * (k + 1)) / 2;
    i = j - 1;
  }
  cout << ans << endl;
  return 0;
}
