#include <bits/stdc++.h>
using namespace std;
long long int dx4[4] = {0, 1, 0, -1};
long long int dy4[4] = {1, 0, -1, 0};
long long int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
long long int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
long long int helper(long long int x) { return (x * (x + 1)) / 2; }
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  long long int ans = 0;
  for (long long int i = 0; i < n;) {
    long long int j = i;
    for (; j < n && arr[i] == arr[j]; j++)
      ;
    ans += helper(j - i);
    i = j;
  }
  cout << ans;
  return 0;
}
