#include <bits/stdc++.h>
using namespace std;
const long long INF = (1ll << 62) - 1;
const int M = 1e5 + 5;
long long ar[100005];
long long cnt = 1, tot, res;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 1; i < n; i++) {
    if (ar[i] == ar[i - 1])
      cnt++;
    else {
      tot = (cnt * (cnt + 1)) / 2;
      res += tot;
      cnt = 1;
    }
  }
  res += (cnt * (cnt + 1)) / 2;
  cout << res << endl;
}
