#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 5e5 + 5;
const int INF = 0x7fffffff;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
int n;
int a[maxn];
long long k[maxn];
map<long long, int> qr;
long long cal(long long a1, long long an, long long d) {
  long long temp = (an - a1) / d + 1;
  return temp * (an + a1) / 2;
}
int main() {
  scanf("%d", &n);
  long long sum = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i == 0) continue;
    if (a[i] == a[i - 1]) {
      ans++;
    } else {
      sum += cal(1, ans + 1, 1);
      ans = 0;
    }
  }
  sum += cal(1, ans + 1, 1);
  cout << sum << endl;
  return 0;
}
