#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 sum2 = n;
    long long count = 0;
    long long count2 = 1;
    for (int i = 1; i < n; ++i) {
      if (num[i] == num[i - 1])
        count++, count2++;
      else {
        sum2 += ((count2 - 1) * (count2)) / 2;
        sum += ((count + 1) * (count)) / 2;
        count = 0;
        count2 = 1;
        if (sum != sum2) cout << i << " " << sum << " " << sum2 << endl;
      }
    }
    if (count != 0) {
      sum2 += ((count2 - 1) * (count2)) / 2;
      sum += ((count + 1) * (count)) / 2;
    }
    if (sum != sum2) cout << n - 1 << " " << sum << " " << sum2 << endl;
    cout << sum2 << endl;
  }
  return 0;
}
