#include <bits/stdc++.h>
using namespace std;
const int M = 500000;
int a[M + 1], n, k;
vector<int> ans;
long long res = 0;
long long foo(int a) {
  long long answer = 1ll * a;
  for (long long i = 2; i <= a; ++i) {
    answer += 1ll + a - i;
  }
  return answer;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  a[n] = 2000000000;
  for (int i = 0; i < n; ++i) {
    if (a[i] == a[i + 1]) {
      int t = 1;
      while (a[i] == a[i + 1]) {
        t++;
        i++;
      }
      ans.push_back(t);
    } else {
      ans.push_back(1);
    }
  }
  for (int i = 0; i < (int)ans.size(); ++i) {
    if (ans[i] == 1)
      res++;
    else
      res += foo(ans[i]);
  }
  cout << res;
}
