#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
int n, a;
int last;
long long ans;
int main() {
  scanf("%d", &n);
  last = -1;
  int cnt = 0;
  for (int i = 0, _n = (n); i < _n; i++) {
    scanf("%d", &a);
    if (a == last)
      cnt++;
    else
      cnt = 1;
    ans += cnt;
    last = a;
  }
  cout << ans << endl;
  return 0;
}
