#include <bits/stdc++.h>
using namespace std;
const long double EPS = 0.00001;
const long double PI = 3.14159265358979323846;
inline void file_io(string in_file, string out_file, bool mark) {
  if (!mark) return;
  freopen(in_file.c_str(), "r", stdin);
  freopen(out_file.c_str(), "w", stdout);
}
const int ML = 1e5 + 1;
int a[ML];
int main() {
  file_io("input.in", "output.out", 0);
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long ans = 0;
  int r = 0;
  for (int i = 0; i < n; ++i) {
    while (r < n && a[i] == a[r]) ++r;
    long long l = (r - i);
    ans += (l * (l + 1)) / 2;
    i = r - 1;
  }
  cout << ans << endl;
  return EXIT_SUCCESS;
}
