#include <bits/stdc++.h>
int main() {
  int banyak;
  int array[100005];
  long long int flag = 0;
  long long int total = 0;
  int balik;
  scanf("%d", &banyak);
  for (int a = 1; a <= banyak; a++) {
    scanf("%d", &array[a]);
  }
  for (int a = 1; a <= banyak; a++) {
    for (balik = a; balik <= banyak; balik++) {
      if (array[a] == array[balik]) {
        flag++;
      } else {
        break;
      }
    }
    total = total + (flag * (flag + 1) / 2);
    flag = 0;
    a = balik - 1;
  }
  printf("%lld", total);
  return 0;
}
