#include <bits/stdc++.h>
using namespace std;
const int maxn = 1.5e5 + 5;
const int inf = 1e9 + 7;
int n;
int p[maxn];
long long ans[maxn];
int mx[maxn << 2], smx[maxn << 2], cnt[maxn << 2];
int bit[maxn];
long long tans = 0;
inline int lowbit(int x) { return x & (-x); }
void add(int pos, int v) {
  for (int i = pos; i <= n; i += lowbit(i)) bit[i] += v;
}
int get(int pos) {
  int tv = 0;
  for (int i = pos; i; i -= lowbit(i)) tv += bit[i];
  return tv;
}
void updata(int rt) {
  if (mx[rt << 1 | 1] == mx[rt << 1]) {
    mx[rt] = mx[rt << 1];
    cnt[rt] = cnt[rt << 1] + cnt[rt << 1 | 1];
    smx[rt] = max(smx[rt << 1], smx[rt << 1 | 1]);
  } else if (mx[rt << 1] > mx[rt << 1 | 1]) {
    mx[rt] = mx[rt << 1];
    cnt[rt] = cnt[rt << 1];
    smx[rt] = max(smx[rt << 1], mx[rt << 1 | 1]);
  } else {
    mx[rt] = mx[rt << 1 | 1];
    cnt[rt] = cnt[rt << 1 | 1];
    smx[rt] = max(mx[rt << 1], smx[rt << 1 | 1]);
  }
}
void color(int rt, int v) {
  if (mx[rt] <= v) return;
  mx[rt] = v;
}
void pushcol(int rt) {
  color(rt << 1, mx[rt]);
  color(rt << 1 | 1, mx[rt]);
}
void build(int l, int r, int rt) {
  if (l == r) {
    cnt[rt] = 1;
    mx[rt] = 0;
    smx[rt] = -inf;
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
  updata(rt);
}
void modifyPos(int l, int r, int rt, int pos, int v) {
  if (l == r) {
    if (v) {
      tans += get(v) - get(l - 1);
    } else if (mx[rt]) {
      tans -= get(mx[rt]) - get(l - 1);
    }
    mx[rt] = v;
    smx[rt] = -inf;
    cnt[rt] = 1;
    return;
  }
  pushcol(rt);
  int mid = (l + r) >> 1;
  if (pos <= mid)
    modifyPos(l, mid, rt << 1, pos, v);
  else
    modifyPos(mid + 1, r, rt << 1 | 1, pos, v);
  updata(rt);
}
void modifyLess(int l, int r, int rt, int nl, int nr, int v) {
  if (nl > nr || mx[rt] <= v) return;
  if (nl <= l && nr >= r && smx[rt] < v) {
    tans += (long long)cnt[rt] * (get(v) - get(mx[rt]));
    color(rt, v);
    return;
  }
  pushcol(rt);
  int mid = (l + r) >> 1;
  if (nl <= mid) modifyLess(l, mid, rt << 1, nl, nr, v);
  if (nr > mid) modifyLess(mid + 1, r, rt << 1 | 1, nl, nr, v);
  updata(rt);
}
void solve() {
  memset(bit, 0, sizeof(bit));
  build(1, n, 1);
  tans = 0;
  for (int i = 1; i <= n; i++) {
    modifyPos(1, n, 1, p[i], 0);
    if (p[i] > 1) modifyLess(1, n, 1, 1, p[i] - 1, p[i] - 1);
    if (p[i] < n) modifyPos(1, n, 1, p[i] + 1, n);
    add(p[i], 1);
    ans[i] += tans;
  }
}
int a[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), p[a[i]] = i;
  solve();
  for (int i = 1; i <= n; i++) p[i] = n - p[i] + 1;
  solve();
  for (int i = 1; i <= n; i++) printf("%lld\n", ans[i] + i);
}
