#include <bits/stdc++.h>
using namespace std;
using std::map;
const int CMAX = 100005;
const char Cfd[] = "", Cfr[] = "";
vector<pair<int, int> > P;
long long sums[CMAX];
int main() {
  int n, a, b;
  cin >> n >> a;
  for (int l = 0; l < n; l++)
    for (int r = l + 1; r < n; r++) {
      cin >> b;
      if (b != a) {
        P.push_back(make_pair(l, r - 1));
        a = b;
        if (r == n - 1) P.push_back(make_pair(r, r));
        l = r - 1;
        break;
      }
      if (a == b && r == n - 1) {
        P.push_back(make_pair(l, r));
        l = r;
        break;
      }
    }
  for (int i = 1; i <= n; i++) sums[i] = sums[i - 1] + (long long)i;
  long long res = 0;
  for (int i = 0; i < P.size(); i++)
    res += (long long)sums[P[i].second - P[i].first + 1];
  cout << (n == 1 ? 1 : res);
  return 0;
}
