#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, a[N];
long long ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= n;) {
    int j = i, len = 0;
    while (j <= n and a[j] == a[i]) ++j, ++len;
    i = j, ans += len * 1LL * (len + 1);
  }
  ans >>= 1;
  cout << ans << endl;
  return 0;
}
