#include <bits/stdc++.h>
using namespace std;
int num[100009];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) cin >> num[i];
    long long sum = n;
    long long count = 1;
    for (int i = 1; i < n; ++i) {
      if (num[i] == num[i - 1])
        count++;
      else {
        sum += ((count - 1) * (count)) / 2;
        count = 1;
      }
    }
    if (count != 0) sum += ((count - 1) * (count)) / 2;
    cout << sum << endl;
  }
  return 0;
}
