#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long p = arr[0], c = 0, a = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == p)
      c++;
    else {
      p = arr[i];
      a += (c * (c + 1)) / 2 - c;
      c = 1;
    }
    if (i == n - 1) a += (c * (c + 1)) / 2 - c;
  }
  cout << a + n << '\n';
  return 0;
}
