#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 0; i < n; i++) cin >> arr[i];
  arr[n] = arr[n - 1] + 1;
  long long ans = 0;
  long long c = 0;
  for (int i = 0; i < n; i++) {
    c = 1;
    while (arr[i + 1] == arr[i]) {
      c++;
      i++;
    }
    ans += (c * (c + 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
