#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int arr[100100];
long long int getInd(long long int x) {
  for (long long int i = x; i <= n; i++) {
    if (arr[x] != arr[i]) return i - 1;
  }
  return n;
}
long long int getVal(long long int x) { return (x * (x + 1)) / 2; }
long long int cal() {
  long long int sum = 0;
  for (long long int i = 1; i <= n; i++) {
    long long int uu = getInd(i);
    long long int vv = (uu - i) + 1;
    sum = sum + getVal(vv);
    i = uu;
  }
  return sum;
}
int main() {
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  cout << cal() << endl;
  return 0;
}
