#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[100005];
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
  int cnt = 1;
  long long ans = 1;
  for (int i = 1; i < n; ++i) {
    if (arr[i] == arr[i - 1])
      cnt++;
    else
      cnt = 1;
    ans += cnt;
  }
  printf("%lld\n", ans);
  return 0;
}
