#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<int> array(n);
    for (int i = 0; i < n; ++i) scanf("%d", &array[i]);
    long long int cnt = 1;
    int prev = array[0];
    long long int ans = 0;
    for (int i = 1; i < array.size(); ++i) {
      if (prev == array[i]) {
        ++cnt;
      } else {
        cnt = cnt * (cnt - 1) / 2;
        ans += cnt;
        cnt = 1;
        prev = array[i];
      }
    }
    cnt = cnt * (cnt - 1) / 2;
    ans += cnt;
    cnt = 1;
    cout << ans + array.size() << endl;
  }
  return 0;
}
