#include <bits/stdc++.h>
using namespace std;
inline void boost() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
}
const long long maxn = 2e5 + 123;
const long long inf = 1e9 + 123;
const long long linf = 1e18 + 123;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double pi = acos(-1);
int dx[4] = {0, 1, -1, 0};
int dy[4] = {1, 0, 0, -1};
int a[maxn];
set<int> s;
int main() {
  boost();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int r = 1;
  long long ans = 0;
  for (int l = 1; l <= n; l++) {
    while (r <= n && a[r] == a[l]) {
      r++;
    }
    ans += (r - l);
  }
  cout << ans;
  return 0;
}
