#include <bits/stdc++.h>
using namespace std;
const long long dx[] = {0, -1, 0, 1};
const long long dy[] = {-1, 0, 1, 0};
const long long INF = 2e9;
const long long nax = 1e7;
const long long M = 1e18 + 7;
void mini(long long &a, long long b) { a = min(a, b); }
void maxi(long long &a, long long b) { a = max(a, b); }
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long &i : a) cin >> i;
  long long i = 0;
  long long ans = 0;
  while (i < n) {
    long long j = i;
    while (j < n && a[i] == a[j]) j++;
    long long nn = j - i;
    ans += nn * (nn + 1) / 2;
    i = j;
  }
  cout << ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  ;
  long long tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
