#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 150000;
struct SegtreeBeatsMin {
  char id;
  int n;
  vector<long long> maxval, maxval2, lazyadd, sum;
  vector<int> maxcnt;
  void sapplymin(int x, long long val) {
    if (val >= maxval[x]) return;
    assert(val > maxval2[x]);
    sum[x] -= maxcnt[x] * (maxval[x] - val);
    maxval[x] = val;
  }
  void sapplyadd(int x, int len, long long val) {
    maxval[x] += val;
    if (maxval2[x] != LLONG_MIN) maxval2[x] += val;
    sum[x] += val * len;
    lazyadd[x] += val;
  }
  void spush(int x, int l, int m, int r) {
    if (lazyadd[x] != 0)
      sapplyadd(x + 1, m - l + 1, lazyadd[x]),
          sapplyadd(x + 2 * (m - l + 1), r - m, lazyadd[x]), lazyadd[x] = 0;
    sapplymin(x + 1, maxval[x]);
    sapplymin(x + 2 * (m - l + 1), maxval[x]);
  }
  void spull(int x, int l, int m, int r) {
    maxval[x] = max(maxval[x + 1], maxval[x + 2 * (m - l + 1)]);
    maxval2[x] =
        max(maxval[x + 1] != maxval[x] ? maxval[x + 1] : maxval2[x + 1],
            maxval[x + 2 * (m - l + 1)] != maxval[x]
                ? maxval[x + 2 * (m - l + 1)]
                : maxval2[x + 2 * (m - l + 1)]);
    sum[x] = sum[x + 1] + sum[x + 2 * (m - l + 1)];
    maxcnt[x] =
        (maxval[x + 1] == maxval[x] ? maxcnt[x + 1] : 0) +
        (maxval[x + 2 * (m - l + 1)] == maxval[x] ? maxcnt[x + 2 * (m - l + 1)]
                                                  : 0);
  }
  void sinit(int x, int l, int r) {
    lazyadd[x] = 0;
    if (l == r) {
      maxval[x] = 0, maxval2[x] = LLONG_MIN, sum[x] = 0, maxcnt[x] = 1;
    } else {
      int m = l + (r - l) / 2;
      sinit(x + 1, l, m);
      sinit(x + 2 * (m - l + 1), m + 1, r);
      spull(x, l, m, r);
    }
  }
  void sset(int x, int l, int r, int IDX, long long VAL) {
    if (l == r) {
      maxval[x] = VAL, maxval2[x] = LLONG_MIN, sum[x] = VAL, maxcnt[x] = 1;
    } else {
      int m = l + (r - l) / 2;
      spush(x, l, m, r);
      if (IDX <= m)
        sset(x + 1, l, m, IDX, VAL);
      else
        sset(x + 2 * (m - l + 1), m + 1, r, IDX, VAL);
      spull(x, l, m, r);
    }
  }
  void sadd(int x, int l, int r, int L, int R, long long VAL) {
    if (L <= l && r <= R) {
      sapplyadd(x, r - l + 1, VAL);
    } else {
      int m = l + (r - l) / 2;
      spush(x, l, m, r);
      if (L <= m) sadd(x + 1, l, m, L, R, VAL);
      if (m + 1 <= R) sadd(x + 2 * (m - l + 1), m + 1, r, L, R, VAL);
      spull(x, l, m, r);
    }
  }
  void smin(int x, int l, int r, int L, int R, long long VAL) {
    if (VAL >= maxval[x]) return;
    if (L <= l && r <= R && VAL > maxval2[x]) {
      sapplymin(x, VAL);
    } else {
      int m = l + (r - l) / 2;
      spush(x, l, m, r);
      if (L <= m) smin(x + 1, l, m, L, R, VAL);
      if (m + 1 <= R) smin(x + 2 * (m - l + 1), m + 1, r, L, R, VAL);
      spull(x, l, m, r);
    }
  }
  long long ssum(int x, int l, int r, int L, int R) {
    if (L <= l && r <= R) {
      return sum[x];
    } else {
      int m = l + (r - l) / 2;
      long long ret = 0;
      spush(x, l, m, r);
      if (L <= m) ret += ssum(x + 1, l, m, L, R);
      if (m + 1 <= R) ret += ssum(x + 2 * (m - l + 1), m + 1, r, L, R);
    }
  }
  void init(int _n) {
    n = _n;
    maxval = maxval2 = lazyadd = sum = vector<long long>(2 * n - 1);
    maxcnt = vector<int>(2 * n - 1);
    sinit(0, 0, n - 1);
  }
  void set(int idx, long long val) { sset(0, 0, n - 1, idx, val); }
  void addrange(int lidx, int ridx, long long val) {
    sadd(0, 0, n - 1, lidx, ridx, val);
  }
  void minrange(int lidx, int ridx, long long val) {
    smin(0, 0, n - 1, lidx, ridx, val);
  }
  long long sumrange(int lidx, int ridx) {
    return ssum(0, 0, n - 1, lidx, ridx);
  }
};
struct SegtreeBeatsMax {
  SegtreeBeatsMin minseg;
  void init(int n) { minseg.init(n); }
  void set(int idx, long long val) { minseg.set(idx, -val); }
  void addrange(int lidx, int ridx, long long val) {
    minseg.addrange(lidx, ridx, -val);
  }
  void maxrange(int lidx, int ridx, long long val) {
    minseg.minrange(lidx, ridx, -val);
  }
  long long sumrange(int lidx, int ridx) {
    return -minseg.sumrange(lidx, ridx);
  }
};
struct BIT {
  int n;
  vector<long long> bit;
  void init(int _n) {
    n = _n;
    bit = vector<long long>(n, 0);
  }
  void add(int idx, long long val) {
    while (idx < n) {
      bit[idx] += val;
      idx |= idx + 1;
    }
  }
  long long prefixsum(int idx) {
    long long ret = 0;
    while (idx >= 0) {
      ret += bit[idx];
      idx = (idx & (idx + 1)) - 1;
    }
    return ret;
  }
};
int n;
int val[MAXN];
long long ans[MAXN];
int pos[MAXN];
BIT bit;
SegtreeBeatsMax segl;
SegtreeBeatsMin segr;
void solve() {
  for (int i = (0); i < (n); ++i) pos[val[i]] = i;
  segl.init(n);
  segl.minseg.id = 'l';
  segr.init(n);
  segr.id = 'r';
  bit.init(n);
  for (int v = (0); v < (n); ++v) {
    int idx = pos[v];
    bit.add(idx, +1);
    int cnt = bit.prefixsum(idx);
    if (idx != 0) segr.minrange(0, idx - 1, cnt - 1);
    segr.set(idx, v + 1);
    if (idx != n - 1) segr.addrange(idx + 1, n - 1, 1);
    segl.set(idx, 0);
    if (idx != n - 1) segl.addrange(idx + 1, n - 1, 1);
    if (idx != n - 1) segl.maxrange(idx + 1, n - 1, cnt);
    ans[v] = segr.sumrange(0, n - 1) - segl.sumrange(0, n - 1);
  }
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &val[i]), --val[i];
  solve();
  for (int i = (0); i < (n); ++i) printf("%lld\n", ans[i]);
}
int main() {
  run();
  return 0;
}
