#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 1) return a;
  if (b == 0) return 1;
  long long temp = power(a, b / 2);
  long long ans = temp * temp;
  if (b & 1) ans *= a;
  return ans;
}
long long power(long long a, long long b, long long p) {
  a = a % p;
  if (b == 1) return a;
  if (b == 0) return 1;
  long long temp = power(a, b / 2, p);
  long long ans = (temp * temp) % p;
  if (b & 1) ans = (a * ans) % p;
  return ans;
}
long long inv(long long a) { return power(a, 1000000007 - 2, 1000000007); }
signed main() {
  ios_base::sync_with_stdio(false);
  long long t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n + 1];
    for (long long i = 1; i <= n; i++) cin >> arr[i];
    long long ans = 0;
    long long i = 1, j;
    while (i <= n) {
      long long cnt = 0;
      long long j = i;
      while (j <= n && arr[j] == arr[i]) cnt++, j++;
      ans += (cnt * (cnt + 1)) / 2;
      i = j;
    }
    cout << ans << '\n';
  }
}
