#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int INF = 1e9 + 5;
const long long mod = 1e9 + 7;
const double pi = 3.1415926536;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long ans = n, cnt = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1]) {
      cnt++;
    } else {
      ans += ((cnt * (cnt - 1)) / 2);
      cnt = 1;
    }
  }
  ans += ((cnt * (cnt - 1)) / 2);
  cout << ans << endl;
  return 0;
}
