#include <bits/stdc++.h>
using namespace std;
void count() {}
int a[100001], dp[100002];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    dp[i] = 1;
    if (i > 1 && a[i] == a[i - 1]) {
      dp[i] += dp[i - 1];
    }
  }
  long long int ans = 0;
  dp[n + 1] = -1;
  for (int i = 1; i <= n; ++i) {
    int cnt = 1;
    while (dp[i] == dp[i + 1] - 1) {
      cnt++, ++i;
    }
    ans += (cnt * 1ll * (cnt + 1) / 2);
  }
  cout << ans << endl;
  return 0;
}
