#include <bits/stdc++.h>
using namespace std;
#define int long long
#define _3bkarm cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(false);
const int inf = 1'000'000'000'000'000'000;
struct node {
int small;
node() {
small = inf;
}
};
struct segment_tree {
int size;
vector<node> tree;
void init(int n) {
size = 1;
while (size < n) {
size <<= 1;
} tree.assign( size << 1, node() );
}
node merge_nodes(node& a, node& b) {
node ret;
ret.small = min(a.small, b.small);
return ret;
}
void build(vector<int>& v, int at, int lx, int rx) {
if (rx - lx == 1) {
if ( lx < v.size() ) {
tree[at].small = v[lx];
}
return;
}
int mid = lx + (rx - lx) / 2;
int left = 2 * at + 1;
int right = 2 * at + 2;
build(v, left, lx, mid);
build(v, right, mid, rx);
tree[at] = merge_nodes(tree[left], tree[right]);
}
void build(vector<int>& v) {
build(v, 0, 0, size);
}
void update(node& at, int val) {
at.small = val;
}
void set(int l, int r, int val, int at, int lx, int rx) {
if (lx >= r or l >= rx) {
return;
}
if (lx >= l and rx <= r) {
update(tree[at], val);
return;
}
int mid = lx + (rx - lx) / 2;
int left = 2 * at + 1;
int right = 2 * at + 2;
set(l, r, val, left, lx, mid);
set(l, r, val, right, mid, rx);
tree[at] = merge_nodes(tree[left], tree[right]);
}
void set(int l, int r, int val) {
set(l, r, val, 0, 0, size);
}
node get(int l, int r, int at, int lx, int rx) {
if (lx >= r or l >= rx) {
return node();
}
if (lx >= l and rx <= r) {
return tree[at];
}
int mid = lx + (rx - lx) / 2;
int left = 2 * at + 1;
int right = 2 * at + 2;
node left_node = get(l, r, left, lx, mid);
node right_node = get(l, r, right, mid, rx);
return merge_nodes(left_node, right_node);
}
node get(int l, int r) {
return get(l, r, 0, 0, size);
}
int next_smaller(int l, int r, int val, int at, int lx, int rx) {
if (lx >= r or l >= rx) {
return -1;
}
if (tree[at].small >= val) {
return -1;
}
if (rx - lx == 1) {
return lx;
}
int m = lx + (rx - lx) / 2;
int left = 2 * at + 1, right = 2 * at + 2;
int ans = next_smaller(l, r, val, left, lx, m);
if (ans == -1) {
return next_smaller(l, r, val, right, m, rx);
}
return ans;
}
int next_smaller(int l, int r, int val) {
return next_smaller(l, r, val, 0, 0, size);
}
};
void get_shit_done() {
int n;
cin >> n;
vector<int> a(n), t(3 * n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
t[i] = a[i];
t[i + n] = a[i];
t[i + 2 * n] = a[i];
}
segment_tree tree;
tree.init(3 * n);
tree.build(t);
vector<int> r(3 * n);
for (int i = 0; i < 3 * n; ++i) {
int p = tree.next_smaller( i + 1, 3 * n, (t[i] + 1) / 2 );
if (p == -1) {
r[i] = 3 * n;
} else {
r[i] = p;
}
}
segment_tree solve;
solve.init(3 * n);
solve.build(r);
for (int i = 0; i < n; ++i) {
int ans = solve.get(i, i + 2 * n).small;
if (ans >= i + 2 * n) {
cout << -1 << ' ';
} else {
cout << ans - i << ' ';
}
}
}
signed main() {
_3bkarm
int ts = 1;
// cin >> ts;
while (ts--) {
get_shit_done();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBpbnQgbG9uZyBsb25nCiNkZWZpbmUgXzNia2FybSBjaW4udGllKE5VTEwpOyBjb3V0LnRpZShOVUxMKTsgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwoKY29uc3QgaW50IGluZiA9IDEnMDAwJzAwMCcwMDAnMDAwJzAwMCcwMDA7CgpzdHJ1Y3Qgbm9kZSB7CiAgICBpbnQgc21hbGw7CgogICAgbm9kZSgpIHsKICAgICAgICBzbWFsbCA9IGluZjsKICAgIH0KfTsKCnN0cnVjdCBzZWdtZW50X3RyZWUgewogICAgaW50IHNpemU7CiAgICB2ZWN0b3I8bm9kZT4gdHJlZTsKCiAgICB2b2lkIGluaXQoaW50IG4pIHsKICAgICAgICBzaXplID0gMTsKICAgICAgICB3aGlsZSAoc2l6ZSA8IG4pIHsKICAgICAgICAgICAgc2l6ZSA8PD0gMTsKICAgICAgICB9IHRyZWUuYXNzaWduKCBzaXplIDw8IDEsIG5vZGUoKSApOwogICAgfQoKICAgIG5vZGUgbWVyZ2Vfbm9kZXMobm9kZSYgYSwgbm9kZSYgYikgewogICAgICAgIG5vZGUgcmV0OwogICAgICAgIHJldC5zbWFsbCA9IG1pbihhLnNtYWxsLCBiLnNtYWxsKTsKICAgICAgICByZXR1cm4gcmV0OwogICAgfQoKICAgIHZvaWQgYnVpbGQodmVjdG9yPGludD4mIHYsIGludCBhdCwgaW50IGx4LCBpbnQgcngpIHsKICAgICAgICBpZiAocnggLSBseCA9PSAxKSB7CiAgICAgICAgICAgIGlmICggbHggPCB2LnNpemUoKSApIHsKICAgICAgICAgICAgICAgIHRyZWVbYXRdLnNtYWxsID0gdltseF07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KCiAgICAgICAgaW50IG1pZCA9IGx4ICsgKHJ4IC0gbHgpIC8gMjsKICAgICAgICBpbnQgbGVmdCA9IDIgKiBhdCArIDE7CiAgICAgICAgaW50IHJpZ2h0ID0gMiAqIGF0ICsgMjsKCiAgICAgICAgYnVpbGQodiwgbGVmdCwgbHgsIG1pZCk7CiAgICAgICAgYnVpbGQodiwgcmlnaHQsIG1pZCwgcngpOwoKICAgICAgICB0cmVlW2F0XSA9IG1lcmdlX25vZGVzKHRyZWVbbGVmdF0sIHRyZWVbcmlnaHRdKTsKICAgIH0KCiAgICB2b2lkIGJ1aWxkKHZlY3RvcjxpbnQ+JiB2KSB7CiAgICAgICAgYnVpbGQodiwgMCwgMCwgc2l6ZSk7CiAgICB9CgogICAgdm9pZCB1cGRhdGUobm9kZSYgYXQsIGludCB2YWwpIHsKICAgICAgICBhdC5zbWFsbCA9IHZhbDsKICAgIH0KCiAgICB2b2lkIHNldChpbnQgbCwgaW50IHIsIGludCB2YWwsIGludCBhdCwgaW50IGx4LCBpbnQgcngpIHsKICAgICAgICBpZiAobHggPj0gciBvciBsID49IHJ4KSB7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CgogICAgICAgIGlmIChseCA+PSBsIGFuZCByeCA8PSByKSB7CiAgICAgICAgICAgIHVwZGF0ZSh0cmVlW2F0XSwgdmFsKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KCiAgICAgICAgaW50IG1pZCA9IGx4ICsgKHJ4IC0gbHgpIC8gMjsKICAgICAgICBpbnQgbGVmdCA9IDIgKiBhdCArIDE7CiAgICAgICAgaW50IHJpZ2h0ID0gMiAqIGF0ICsgMjsKCiAgICAgICAgc2V0KGwsIHIsIHZhbCwgbGVmdCwgbHgsIG1pZCk7CiAgICAgICAgc2V0KGwsIHIsIHZhbCwgcmlnaHQsIG1pZCwgcngpOwoKICAgICAgICB0cmVlW2F0XSA9IG1lcmdlX25vZGVzKHRyZWVbbGVmdF0sIHRyZWVbcmlnaHRdKTsKICAgIH0KCiAgICB2b2lkIHNldChpbnQgbCwgaW50IHIsIGludCB2YWwpIHsKICAgICAgICBzZXQobCwgciwgdmFsLCAwLCAwLCBzaXplKTsKICAgIH0KCiAgICBub2RlIGdldChpbnQgbCwgaW50IHIsIGludCBhdCwgaW50IGx4LCBpbnQgcngpIHsKICAgICAgICBpZiAobHggPj0gciBvciBsID49IHJ4KSB7CiAgICAgICAgICAgIHJldHVybiBub2RlKCk7CiAgICAgICAgfQoKICAgICAgICBpZiAobHggPj0gbCBhbmQgcnggPD0gcikgewogICAgICAgICAgICByZXR1cm4gdHJlZVthdF07CiAgICAgICAgfQoKICAgICAgICBpbnQgbWlkID0gbHggKyAocnggLSBseCkgLyAyOwogICAgICAgIGludCBsZWZ0ID0gMiAqIGF0ICsgMTsKICAgICAgICBpbnQgcmlnaHQgPSAyICogYXQgKyAyOwoKICAgICAgICBub2RlIGxlZnRfbm9kZSA9IGdldChsLCByLCBsZWZ0LCBseCwgbWlkKTsKICAgICAgICBub2RlIHJpZ2h0X25vZGUgPSBnZXQobCwgciwgcmlnaHQsIG1pZCwgcngpOwoKICAgICAgICByZXR1cm4gbWVyZ2Vfbm9kZXMobGVmdF9ub2RlLCByaWdodF9ub2RlKTsKICAgIH0KCiAgICBub2RlIGdldChpbnQgbCwgaW50IHIpIHsKICAgICAgICByZXR1cm4gZ2V0KGwsIHIsIDAsIDAsIHNpemUpOwogICAgfQoKICAgIGludCBuZXh0X3NtYWxsZXIoaW50IGwsIGludCByLCBpbnQgdmFsLCBpbnQgYXQsIGludCBseCwgaW50IHJ4KSB7CiAgICAgICAgaWYgKGx4ID49IHIgb3IgbCA+PSByeCkgewogICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgfQogICAgICAgIGlmICh0cmVlW2F0XS5zbWFsbCA+PSB2YWwpIHsKICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgIH0KICAgICAgICBpZiAocnggLSBseCA9PSAxKSB7CiAgICAgICAgICAgIHJldHVybiBseDsKICAgICAgICB9CgogICAgICAgIGludCBtID0gbHggKyAocnggLSBseCkgLyAyOwogICAgICAgIGludCBsZWZ0ID0gMiAqIGF0ICsgMSwgcmlnaHQgPSAyICogYXQgKyAyOwoKICAgICAgICBpbnQgYW5zID0gbmV4dF9zbWFsbGVyKGwsIHIsIHZhbCwgbGVmdCwgbHgsIG0pOwoKICAgICAgICBpZiAoYW5zID09IC0xKSB7CiAgICAgICAgICAgIHJldHVybiBuZXh0X3NtYWxsZXIobCwgciwgdmFsLCByaWdodCwgbSwgcngpOwogICAgICAgIH0KCiAgICAgICAgcmV0dXJuIGFuczsKICAgIH0KCiAgICBpbnQgbmV4dF9zbWFsbGVyKGludCBsLCBpbnQgciwgaW50IHZhbCkgewogICAgICAgIHJldHVybiBuZXh0X3NtYWxsZXIobCwgciwgdmFsLCAwLCAwLCBzaXplKTsKICAgIH0KfTsKCnZvaWQgZ2V0X3NoaXRfZG9uZSgpIHsKICAgIGludCBuOwogICAgY2luID4+IG47CgogICAgdmVjdG9yPGludD4gYShuKSwgdCgzICogbik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewogICAgICAgIGNpbiA+PiBhW2ldOwogICAgICAgIHRbaV0gPSBhW2ldOwogICAgICAgIHRbaSArIG5dID0gYVtpXTsKICAgICAgICB0W2kgKyAyICogbl0gPSBhW2ldOwogICAgfQoKICAgIHNlZ21lbnRfdHJlZSB0cmVlOwogICAgdHJlZS5pbml0KDMgKiBuKTsKICAgIHRyZWUuYnVpbGQodCk7CgogICAgdmVjdG9yPGludD4gcigzICogbik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IDMgKiBuOyArK2kpIHsKICAgICAgICBpbnQgcCA9IHRyZWUubmV4dF9zbWFsbGVyKCBpICsgMSwgMyAqIG4sICh0W2ldICsgMSkgLyAyICk7CiAgICAgICAgaWYgKHAgPT0gLTEpIHsKICAgICAgICAgICAgcltpXSA9IDMgKiBuOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJbaV0gPSBwOwogICAgICAgIH0KICAgIH0KCiAgICBzZWdtZW50X3RyZWUgc29sdmU7CiAgICBzb2x2ZS5pbml0KDMgKiBuKTsKICAgIHNvbHZlLmJ1aWxkKHIpOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgaW50IGFucyA9IHNvbHZlLmdldChpLCBpICsgMiAqIG4pLnNtYWxsOwogICAgICAgIGlmIChhbnMgPj0gaSArIDIgKiBuKSB7CiAgICAgICAgICAgIGNvdXQgPDwgLTEgPDwgJyAnOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGNvdXQgPDwgYW5zIC0gaSA8PCAnICc7CiAgICAgICAgfQogICAgfQp9CgpzaWduZWQgbWFpbigpIHsKICAgIF8zYmthcm0KCiAgICBpbnQgdHMgPSAxOwovLyAgICBjaW4gPj4gdHM7CiAgICB3aGlsZSAodHMtLSkgewogICAgICAgIGdldF9zaGl0X2RvbmUoKTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQ==