#include <bits/stdc++.h>
using namespace std;
int arr1[51], arr2[51];
int main() {
  long long int n, p = 0, i, ans = 0, cnt = 0;
  cin >> n;
  long long int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  for (i = 0; i < n - 1; i++) {
    cnt = 1;
    p = 0;
    while ((arr[i] == arr[i + 1]) && (i < n - 1)) {
      cnt++;
      i++;
      p = 1;
    }
    ans += ((cnt * (cnt - 1)) / 2);
    if (p == 1) i = i - 1;
  }
  ans += n;
  cout << ans;
  return 0;
}
