#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> v;
  long long a;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  long long cnt = 0, res = 0, mx, mn;
  for (long long i = 0; i < n; i++) {
    mx = v[i];
    mn = v[i];
    cnt = 1;
    for (long long j = i + 1; j < n; j++) {
      if (v[i] == v[j])
        cnt++;
      else
        break;
      i = j;
    }
    res = res + ((cnt * (cnt + 1)) / 2);
  }
  cout << res << endl;
  return 0;
}
