#include <bits/stdc++.h>
using namespace std;
long long num[200000];
unsigned long long ans;
int main() {
  int n;
  while (cin >> n) {
    ans = 0;
    vector<unsigned long long> nu;
    for (int i = 0; i < n; ++i) cin >> num[i];
    int i = 0;
    nu.push_back(1);
    for (int j = 1; j < n; ++j) {
      if (num[j] == num[j - 1])
        ++nu[i];
      else {
        ++i;
        nu.push_back(1);
      }
    }
    for (int i = 0; i < nu.size(); ++i) ans += (((nu[i] + 1) * nu[i]) / 2);
    cout << ans << endl;
  }
}
