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