#include <bits/stdc++.h>
using namespace std;
long long a, b[100009];
bool c[100009];
long long sm, co;
int main() {
  cin >> a;
  for (int i = 1; i <= a; i++) cin >> b[i];
  co = 1;
  for (int i = 1; i < a; i++) {
    if (b[i] == b[i + 1])
      co++, c[i] = 1, c[i + 1] = 1;
    else if (co > 1)
      sm += (co * (co + 1)) / 2, co = 1;
  }
  if (co > 1) sm += (co * (co + 1)) / 2;
  for (int i = 1; i <= a; i++)
    if (c[i] == 0) sm++;
  cout << sm << endl;
  return 0;
}
