#include <bits/stdc++.h>
using namespace std;
long long int numdigit(long long int n) { return floor(log10(n)) + 1; }
bool isPowerTwo(long long int x) { return x && (!(x & (x - 1))); }
const int sz = 1e5 + 5;
long long int ar[sz];
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    long long int ans = 0;
    for (int i = 0; i < n; i++) cin >> ar[i];
    long long int ct = 1;
    for (int i = 1; i < n; i++) {
      if (ar[i] == ar[i - 1]) {
        ct++;
      } else {
        ans += ((ct) * (ct + 1)) / 2;
        ct = 1;
      }
    }
    ans += (ct * (ct + 1)) / 2;
    cout << ans << "\n";
  }
  return 0;
}
