#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long int lol(long long int n) { return (n * (n + 1)) / 2; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  long long int in[n], sans = n, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  long long int count = 1;
  for (int i = 1; i < n; i++) {
    if (in[i] == in[i - 1]) {
      count++;
    } else if (count != 1) {
      ans += lol(count);
      sans -= count;
      count = 1;
    }
  }
  if (count > 1) {
    ans += lol(count);
    sans -= count;
  }
  ans += sans;
  cout << ans << "\n";
  return 0;
}
