#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
int n, m, i, j, a[150005], p[150005];
long long ans;
struct seg {
  int s[150005];
  void add(int x, int y) {
    while (x <= n) {
      s[x] += y;
      x += (x & -x);
    }
  }
  int query(int x) {
    int ss = 0;
    while (x) {
      ss += s[x];
      x -= (x & -x);
    }
    return ss;
  }
  struct ii {
    int mx, smx, num;
  } tr[600005];
  int tag[600005];
  ii merge(ii x, ii y) {
    ii z;
    z.mx = max(x.mx, y.mx);
    z.smx = 0;
    z.num = 0;
    if (x.mx != z.mx)
      z.smx = max(z.smx, x.mx);
    else
      z.num += x.num;
    if (y.mx != z.mx)
      z.smx = max(z.smx, y.mx);
    else
      z.num += y.num;
    if (x.smx != z.mx) z.smx = max(z.smx, x.smx);
    if (y.smx != z.mx) z.smx = max(z.smx, y.smx);
    return z;
  }
  void pushup(int x) { tr[x] = merge(tr[x + x], tr[x + x + 1]); }
  void upd(int x, int y) {
    tag[x] = min(tag[x], y);
    tr[x].mx = min(tr[x].mx, y);
  }
  void pushdo(int x) {
    upd(x + x, tag[x]);
    upd(x + x + 1, tag[x]);
    tag[x] = n;
  }
  void update1(int x, int l, int r, int y, int c) {
    if (l == r) {
      tr[x].num = 1;
      tr[x].mx = c;
      tr[x].smx = 0;
      return;
    }
    pushdo(x);
    int mid = (l + r) / 2;
    if (y <= mid)
      update1(x + x, l, mid, y, c);
    else
      update1(x + x + 1, mid + 1, r, y, c);
    pushup(x);
  }
  void update2(int x, int l, int r, int ql, int qr, int c) {
    if (ql <= l && r <= qr) {
      if (c >= tr[x].mx) {
        return;
      }
      if (c > tr[x].smx) {
        ans -= 1ll * tr[x].num * (query(tr[x].mx) - query(c));
        upd(x, c);
        return;
      }
    }
    pushdo(x);
    int mid = (l + r) / 2;
    if (ql <= mid) update2(x + x, l, mid, ql, qr, c);
    if (qr > mid) update2(x + x + 1, mid + 1, r, ql, qr, c);
    pushup(x);
  }
  void build(int x, int l, int r) {
    tr[x].mx = tr[x].smx = tr[x].num = 0;
    tag[x] = n;
    if (l == r) {
      return;
    }
    int mid = (l + r) / 2;
    build(x + x, l, mid);
    build(x + x + 1, mid + 1, r);
  }
} t1, t2;
int main() {
  read(n);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    read(a[i]);
    p[a[i]] = i;
  }
  t1.build(1, 1, n);
  t1.build(1, 1, n);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    int x = p[i];
    if (x > 1) t1.update2(1, 1, n, 1, x - 1, x - 1);
    if (x < n) t2.update2(1, 1, n, 1, n - x, n - x);
    t1.add(x, 1);
    t2.add(n - x + 1, 1);
    t1.update1(1, 1, n, x, n);
    t2.update1(1, 1, n, n - x + 1, n);
    ans += i;
    printf("%lld\n", ans);
  }
  return 0;
}
