#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long LINF = 1000000000000000000LL;
void prepare() {}
int n, a[100005];
bool solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  long long ans = 0LL;
  int count = 0;
  for (int i = 0; i < n; i++) {
    count = 0;
    int j = i;
    while (a[j] == a[i] && j < n) {
      count++;
      j++;
    }
    i = j - 1;
    long long t = count;
    ans += t * (t + 1) / 2;
  }
  cout << ans << endl;
  return false;
}
int main() {
  prepare();
  while (solve())
    ;
  return 0;
}
