#include <bits/stdc++.h>
using namespace std;
int dp[200][200];
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int> > a;
  int i = 0, k = 0;
  while (i < n) {
    int x;
    cin >> x;
    if (i == 0 || a[k - 1].first != x) {
      a.push_back({x, 1});
      k++;
    } else
      a[k - 1].second++;
    i++;
  }
  long long res = 0;
  for (int j = 0; j < a.size(); j++) {
    long long x = a[j].second;
    res += x * (x + 1) / 2;
  }
  cout << res;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
