#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:20000000")
string problem_name = "a";
void init() { freopen((problem_name + ".in").c_str(), "rt", stdin); }
int mas[100100];
int main() {
  int n;
  cin >> n;
  long long res = 0;
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    cin >> mas[i];
    if (mas[i] != mas[i - 1] || !i) {
      cur = 1;
      res++;
    } else {
      cur++;
      res += cur;
    }
  }
  cout << res;
  return 0;
}
