#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
int aim[maxn], n;
long long num[maxn];
int main() {
  for (int i = 0; i < maxn; i++) num[i] = 1;
  cin >> n;
  cin >> aim[1];
  for (int i = 2; i <= n; i++) {
    cin >> aim[i];
    if (aim[i] == aim[i - 1]) num[i] = num[i - 1] + 1;
  }
  long long ans = 0, t;
  int i = 1;
  while (i <= n) {
    t = num[i];
    if (i == n) {
      ans += t * (t + 1) / 2;
      break;
    }
    if (num[i + 1] != 1) {
      i++;
      continue;
    }
    ans += t * (t + 1) / 2;
    i++;
  }
  cout << ans << endl;
  return 0;
}
