#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int N;
int A[100100];
long long ans;
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin >> N;
  for (int(i) = 1, j123 = N; (i) <= j123; (i)++) cin >> A[i];
  for (int i = 1; i <= N;) {
    int j = i;
    while (j + 1 <= N && A[j + 1] == A[i]) j = j + 1;
    long long n = j - i + 1;
    ans += n * (n + 1) / 2;
    i = j + 1;
  }
  cout << ans << '\n';
}
