Your favorite music streaming platform has formed a perfectly balanced playlist exclusively for you. The playlist consists of $n$ tracks numbered from $1$ to $n$. The playlist is automatic and cyclic: whenever track $i$ finishes playing, track $i+1$ starts playing automatically; after track $n$ goes track $1$.

For each track $i$, you have estimated its coolness $a_i$. The higher $a_i$ is, the cooler track $i$ is.

Every morning, you choose a track. The playlist then starts playing from this track in its usual cyclic fashion. At any moment, you remember the maximum coolness $x$ of already played tracks. Once you hear that a track with coolness strictly less than $\frac{x}{2}$ (no rounding) starts playing, you turn off the music immediately to keep yourself in a good mood.

For each track $i$, find out how many tracks you will listen to before turning off the music if you start your morning with track $i$, or determine that you will never turn the music off. Note that if you listen to the same track several times, every time must be counted.


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 10^5$), denoting the number of tracks in the playlist.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$), denoting coolnesses of the tracks.


-----Output-----

Output $n$ integers $c_1, c_2, \ldots, c_n$, where $c_i$ is either the number of tracks you will listen to if you start listening from track $i$ or $-1$ if you will be listening to music indefinitely.


-----Examples-----
Input
4
11 5 2 7

Output
1 1 3 2

Input
4
3 2 5 3

Output
5 4 3 6

Input
3
4 3 6

Output
-1 -1 -1



-----Note-----

In the first example, here is what will happen if you start with...   track $1$: listen to track $1$, stop as $a_2 < \frac{a_1}{2}$.  track $2$: listen to track $2$, stop as $a_3 < \frac{a_2}{2}$.  track $3$: listen to track $3$, listen to track $4$, listen to track $1$, stop as $a_2 < \frac{\max(a_3, a_4, a_1)}{2}$.  track $4$: listen to track $4$, listen to track $1$, stop as $a_2 < \frac{\max(a_4, a_1)}{2}$. 

In the second example, if you start with track $4$, you will listen to track $4$, listen to track $1$, listen to track $2$, listen to track $3$, listen to track $4$ again, listen to track $1$ again, and stop as $a_2 < \frac{max(a_4, a_1, a_2, a_3, a_4, a_1)}{2}$. Note that both track $1$ and track $4$ are counted twice towards the result.

Source: codeforces | Difficulty: HARD
Tags: Sorting

Data structures

Implementation


Solutions:
max2 = lambda x, y: x if x > y else y
min2 = lambda x, y: x if x < y else y

def bisect_rev(a, v, l):
	r = len(a)
	while l + 1 < r:
		m = (l + r) // 2
		if a[m] <= v:
			r = m
		else:
			l = m
	return l
import sys
from bisect import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def solve(A):
	N = len(A)
	pairs = []
	stack_val = [10 ** 9 + 1, A[0]]
	stack_ind = [-1, 0]
	l = 1
	for (i, a) in enumerate(A + A):
		if a * 2 < stack_val[l]:
			k = bisect_rev(stack_val, a * 2, l)
			j = stack_ind[k]
			if j >= N:
				break
			l = k + 1
			pairs.append((j, i))
		while stack_val[-1] <= a:
			stack_val.pop()
			stack_ind.pop()
		stack_val.append(a)
		stack_ind.append(i)
		l = min2(l, len(stack_ind) - 1)
	if not pairs:
		return [-1] * N
	pairs.append((pairs[0][0] + N, pairs[0][1] + N))
	res = [0] * N
	pi = 0
	(ns, nt) = pairs[pi]
	for i in range(N):
		res[i] = nt - i
		if i == ns:
			pi += 1
			(ns, nt) = pairs[pi]
	return res

def naive(A):
	N = len(A)
	res = [0] * N
	for i in range(N):
		m = A[i]
		for k in range(N * 2):
			if 2 * A[(i + k) % N] < m:
				res[i] = k
				break
			m = max2(m, A[(i + k) % N])
		else:
			res[i] = -1
	return res
from random import randrange

def test():
	N = 4
	for _ in range(100000):
		A = [randrange(32) for _ in range(N)]
		r1 = solve(A)
		r2 = naive(A)
		if r1 != r2:
			print(A)
			print(r1, r2)
			break
N = int(readline())
A = tuple(map(int, readline().split()))
print(*solve(A))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

class Binary_Indexed_Tree:

	def __init__(self, n):
		self.n = n
		self.data = [0] * (n + 1)

	def add(self, i, x):
		while i <= self.n:
			self.data[i] += x
			i += i & -i

	def get(self, i):
		return self.sum_range(i, i)

	def sum(self, i):
		ret = 0
		while i:
			ret += self.data[i]
			i &= i - 1
		return ret

	def sum_range(self, l, r):
		return self.sum(r) - self.sum(l - 1)

	def lower_bound(self, w):
		if w <= 0:
			return 0
		i = 0
		k = 1 << self.n.bit_length()
		while k:
			if i + k <= self.n and self.data[i + k] < w:
				w -= self.data[i + k]
				i += k
			k >>= 1
		return i + 1

class RangeMinimumQuery:

	def __init__(self, n, func=min, inf=float('inf')):
		self.n0 = 2 ** (n - 1).bit_length()
		self.op = func
		self.inf = inf
		self.data = [self.inf] * (2 * self.n0)

	def construct(self, lis):
		for (i, x) in enumerate(lis):
			self.data[i + self.n0 - 1] = x
		for i in range(self.n0 - 2, -1, -1):
			self.data[i] = self.op(self.data[2 * i + 1], self.data[2 * i + 2])

	def query(self, l, r):
		l += self.n0
		r += self.n0
		res = self.inf
		while l < r:
			if r & 1:
				r -= 1
				res = self.op(res, self.data[r - 1])
			if l & 1:
				res = self.op(res, self.data[l - 1])
				l += 1
			l >>= 1
			r >>= 1
		return res
n = int(input())
a = list(map(int, input().split()))
a = [i * 2 for i in a]
BIT = Binary_Indexed_Tree(2 * n)
RMQ = RangeMinimumQuery(2 * n)
RMQ.construct(a + a)
b = [[j, i] for (i, j) in enumerate(a)]
b.sort(reverse=True)
ans = [0] * n
for (j, i) in b:
	cnt = BIT.sum(2 * n - i)
	tmp = float('inf')
	if cnt:
		p = 2 * n - BIT.lower_bound(cnt)
		tmp = p - i + ans[p % n]
	BIT.add(2 * n - i, 1)
	BIT.add(n - i, 1)
	left = i
	right = 2 * n
	if RMQ.query(i, right) < j // 2:
		while right - left > 1:
			mid = (right + left) // 2
			if RMQ.query(i, mid) < j // 2:
				right = mid
			else:
				left = mid
		tmp = min(tmp, right - i - 1)
	ans[i] = tmp
ans = [i if i != float('inf') else -1 for i in ans]
print(*ans)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
B = [(-a, i) for (i, a) in enumerate(A)]
from collections import deque
LIST = deque()
LIST.append(B[0])
for (b, i) in B[1:]:
	if b > LIST[-1][0]:
		LIST.append((b, i))
import bisect
DIS = [-1] * n
for i in range(n - 1, -1, -1):
	x = bisect.bisect(LIST, (-A[i] // 2, 1 << 20))
	if x < len(LIST):
		DIS[i] = LIST[x][1]
	while len(LIST) >= 1 and A[i] <= -LIST[0][0]:
		LIST.popleft()
	LIST.appendleft(B[i])
if max(DIS) == -1:
	print(*[-1] * n)
	return
for i in range(n):
	if DIS[i] != -1:
		start = i
		break
ANS = [-1] * n
if DIS[start] > start:
	ANS[start] = DIS[start] - start
else:
	ANS[start] = DIS[start] + (n - start)
for i in range(start - 1, -1, -1):
	if DIS[i] == -1:
		ANS[i] = ANS[(i + 1) % n] + 1
	elif DIS[i] > i:
		ANS[i] = min(DIS[i] - i, ANS[(i + 1) % n] + 1)
	else:
		ANS[i] = min(DIS[i] + (n - i), ANS[(i + 1) % n] + 1)
for i in range(n - 1, -1, -1):
	if DIS[i] == -1:
		ANS[i] = ANS[(i + 1) % n] + 1
	elif DIS[i] > i:
		ANS[i] = min(DIS[i] - i, ANS[(i + 1) % n] + 1)
	else:
		ANS[i] = min(DIS[i] + (n - i), ANS[(i + 1) % n] + 1)
for i in range(n - 1, -1, -1):
	if DIS[i] == -1:
		ANS[i] = ANS[(i + 1) % n] + 1
	elif DIS[i] > i:
		ANS[i] = min(DIS[i] - i, ANS[(i + 1) % n] + 1)
	else:
		ANS[i] = min(DIS[i] + (n - i), ANS[(i + 1) % n] + 1)
print(*ANS)


def solver():
	n = int(input())
	num = list(map(int, input().split()))
	a = num + num + num
	ans = [0] * (3 * n)
	maxn = []
	minn = []
	for i in range(len(a) - 1, -1, -1):
		while len(maxn) > 0 and a[maxn[-1]] < a[i]:
			maxn.pop()
		while len(minn) > 0 and a[minn[-1]] > a[i]:
			minn.pop()
		(left, right) = (0, len(minn))
		while left < right:
			mid = (left + right) // 2
			if a[minn[mid]] * 2 < a[i]:
				left = mid + 1
			else:
				right = mid
		ret = 3 * n
		if left > 0:
			ret = min(ret, minn[left - 1])
		if len(maxn) > 0:
			ret = min(ret, maxn[-1])
		if ret < 3 * n and a[ret] >= a[i]:
			ans[i] = ans[ret]
		else:
			ans[i] = ret
		maxn.append(i)
		minn.append(i)
	for i in range(n):
		print(-1 if ans[i] == 3 * n else ans[i] - i)

def main():
	while 1:
		try:
			solver()
		except EOFError:
			break
main()


from collections import deque
n = int(input())
arr = list(map(int, input().split()))
ans = [-1] * n
queue = deque()
maximum = 0
j = 0
for i in range(3 * n):
	while queue and arr[i % n] * 2 < queue[0][0]:
		[val, index] = queue.popleft()
		while j <= index and j < n:
			ans[j] = i - j
			j += 1
	while queue and arr[i % n] >= queue[-1][0]:
		queue.pop()
	queue.append([arr[i % n], i])
ans = ' '.join(map(str, ans))
print(ans)


import sys
input = sys.stdin.readline

class SegTree(object):

	def __init__(self, n, arr):
		self.n = n
		self.arr = arr
		self.tree = [0 for i in range(2 * n)]

	def construct(self):
		for i in range(self.n):
			self.tree[n + i] = self.arr[i]
		for i in range(n - 1, 0, -1):
			self.tree[i] = self.function(self.tree[2 * i], self.tree[2 * i + 1])

	def update(self, index, change):
		start = index + self.n
		self.tree[start] = value
		while start > 0:
			self.tree[start] = self.function(self.tree[2 * start], self.tree[2 * start + 1])
			start = start // 2

	def calc(self, low, high):
		low += self.n
		high += self.n
		ans = 0
		while low < high:
			if low % 2:
				ans = self.function(ans, self.tree[low])
				low += 1
			if high % 2:
				high -= 1
				ans = self.function(ans, self.tree[high])
			low = low // 2
			high = high // 2
		return ans

	def function(self, a, b):
		return max(a, b)
n = int(input()) * 3
a = list(map(int, input().split()))
a = a + a + a
st = SegTree(n, a)
st.construct()
ans = [-1] * n
m = a[0]
flag = 0
for i in range(1, n):
	if a[i] <= (m - 1) // 2:
		ans[0] = i
		flag = 1
		prev = i
		break
	else:
		m = max(m, a[i])
if not flag:
	print(*ans[0:n // 3])
	return
for i in range(1, n // 3):
	if a[i] >= a[i - 1]:
		ans[i] = ans[i - 1] - 1
	else:
		maxx = st.calc(i, prev + 1)
		while a[prev] > (maxx - 1) // 2:
			maxx = max(maxx, a[prev])
			prev += 1
		ans[i] = prev - i
print(*ans[0:n // 3])


import types
_atcoder_code = '\n# Python port of AtCoder Library.\n__all__ = ["string","lazysegtree","convolution","maxflow","modint"\n    ,"mincostflow","segtree","_scc","_math","math","dsu","twosat","fenwicktree","scc","_bit","lca","unverified","graph","matrix","algebra","combinatorics"]\n__version__ = \'0.0.1\'\n'
atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)
_atcoder__bit_code = '\ndef _ceil_pow2(n: int) -> int:\n    x = 0\n    while (1 << x) < n:\n        x += 1\n\n    return x\n\n\ndef _bsf(n: int) -> int:\n    x = 0\n    while n % 2 == 0:\n        x += 1\n        n //= 2\n\n    return x\n'
atcoder._bit = types.ModuleType('atcoder._bit')
exec(_atcoder__bit_code, atcoder._bit.__dict__)
_atcoder_segtree_code = "\nimport typing\n\n# import atcoder._bit\n\n\nclass SegTree:\n \n    '''\n    Segment Tree Library.\n    op(S,S) -> S\n    e = Identity element\n    \n    SegTree(op,e,n) := Initialized by [e]*(n)\n    SegTree(op,e,vector) := Initialized by vector\n    '''\n\n    def __init__(self,\n                 op: typing.Callable[[typing.Any, typing.Any], typing.Any],\n                 e: typing.Any,\n                 v: typing.Union[int, typing.List[typing.Any]]) -> None:\n        self._op = op\n        self._e = e\n\n        if isinstance(v, int):\n            v = [e] * v\n\n        self._n = len(v)\n        self._log = atcoder._bit._ceil_pow2(self._n)\n        self._size = 1 << self._log\n        self._d = [e] * (2 * self._size)\n\n        for i in range(self._n):\n            self._d[self._size + i] = v[i]\n        for i in range(self._size - 1, 0, -1):\n            self._update(i)\n\n    def set(self, p: int, x: typing.Any) -> None:\n        '''\n        a[p] -> x in O(logN).\n        '''\n        assert 0 <= p < self._n\n\n        p += self._size\n        self._d[p] = x\n        for i in range(1, self._log + 1):\n            self._update(p >> i)\n\n    def increment(self, p: int, x : typing.Any) -> None:\n        '''\n        a[p] -> a[p] + x in O(logN).\n        '''\n        assert 0 <= p < self._n\n\n        p += self._size\n        self._d[p] += x\n        for i in range(1,self._log + 1):\n            self._update(p >> i)\n        \n    def get(self, p: int) -> typing.Any:\n        '''\n        return a[p] in O(1).\n        '''\n        assert 0 <= p < self._n\n\n        return self._d[p + self._size]\n\n    def prod(self, left: int, right: int) -> typing.Any:\n        '''\n        return op(a[l...r)) in O(logN).\n        '''\n        assert 0 <= left <= right <= self._n\n        sml = self._e\n        smr = self._e\n        left += self._size\n        right += self._size\n\n        while left < right:\n            if left & 1:\n                sml = self._op(sml, self._d[left])\n                left += 1\n            if right & 1:\n                right -= 1\n                smr = self._op(self._d[right], smr)\n            left >>= 1\n            right >>= 1\n\n        return self._op(sml, smr)\n\n    def all_prod(self) -> typing.Any:\n        return self._d[1]\n\n    def max_right(self, left: int,\n                  f: typing.Callable[[typing.Any], bool]) -> int:\n        '''\n        let f(S) -> bool and l is const.\n        return maximum r for which f(op[l...r)) == true is satisfied, in O(logN).\n        '''\n        assert 0 <= left <= self._n\n        # assert f(self._e)\n\n        if left == self._n:\n            return self._n\n\n        left += self._size\n        sm = self._e\n\n        first = True\n        while first or (left & -left) != left:\n            first = False\n            while left % 2 == 0:\n                left >>= 1\n            if not f(self._op(sm, self._d[left])):\n                while left < self._size:\n                    left *= 2\n                    if f(self._op(sm, self._d[left])):\n                        sm = self._op(sm, self._d[left])\n                        left += 1\n                return left - self._size\n            sm = self._op(sm, self._d[left])\n            left += 1\n\n        return self._n\n\n    def min_left(self, right: int,\n                 f: typing.Callable[[typing.Any], bool]) -> int:\n        '''\n        let f(S) -> bool and r is const.\n        return minimum l for which f(op[l...r)) == true is satisfied, in O(logN).\n        '''\n\n        assert 0 <= right <= self._n\n        # assert f(self._e)\n\n        if right == 0:\n            return 0\n\n        right += self._size\n        sm = self._e\n\n        first = True\n        while first or (right & -right) != right:\n            first = False\n            right -= 1\n            while right > 1 and right % 2:\n                right >>= 1\n            if not f(self._op(self._d[right], sm)):\n                while right < self._size:\n                    right = 2 * right + 1\n                    if f(self._op(self._d[right], sm)):\n                        sm = self._op(self._d[right], sm)\n                        right -= 1\n                return right + 1 - self._size\n            sm = self._op(self._d[right], sm)\n\n        return 0\n\n    def _update(self, k: int) -> None:\n        self._d[k] = self._op(self._d[2 * k], self._d[2 * k + 1])\n"
atcoder.segtree = types.ModuleType('atcoder.segtree')
atcoder.segtree.__dict__['atcoder'] = atcoder
atcoder.segtree.__dict__['atcoder._bit'] = atcoder._bit
exec(_atcoder_segtree_code, atcoder.segtree.__dict__)
SegTree = atcoder.segtree.SegTree
import sys

def input():
	return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]
INF = 1 << 32

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a1 = a * 2 + [INF]
	a2 = a * 2 + [-INF]
	maxS = SegTree(lambda x, y: max(x, y), -INF, a1)
	minS = SegTree(lambda x, y: min(x, y), INF, a2)
	dp = [-1] * (2 * n)
	b = [(a[i], i) for i in range(n)]
	b.sort(key=lambda x: -x[0])
	for (val, idx) in b:
		right_bound_idx = maxS.max_right(idx, lambda x: x <= val)
		if right_bound_idx != 2 * n:
			right_bound_idx_0 = minS.max_right(idx, lambda x: 2 * x >= val)
			if right_bound_idx_0 < right_bound_idx:
				dp[idx] = right_bound_idx_0 - idx
				dp[idx + n] = dp[idx]
				continue
			else:
				if dp[right_bound_idx] != -1:
					dp[idx] = dp[right_bound_idx] + (right_bound_idx - idx)
				else:
					dp[idx] = -1
				dp[idx + n] = dp[idx]
				continue
		else:
			right_bound_idx = minS.max_right(idx, lambda x: 2 * x >= val)
			if right_bound_idx == 2 * n:
				dp[idx] = -1
			else:
				dp[idx] = right_bound_idx - idx
			dp[idx + n] = dp[idx]
	print(*dp[:n])
	return 0
main()


class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

class OrderedList(SortedList):

	def __init__(self, arg):
		super().__init__(arg)

	def rangeCountByValue(self, leftVal, rightVal):
		leftCummulative = self.bisect_left(leftVal)
		rightCummulative = self.bisect_left(rightVal + 1)
		return rightCummulative - leftCummulative

def main():
	n = int(input())
	a = readIntArr()
	a = a + a + a
	ol = OrderedList([])
	stoppingTrack = [inf] * (2 * n)
	for i in range(2 * n):
		searchVal = 2 * a[i] + 1
		searchArr = [searchVal, -1]
		while True:
			j = ol.bisect_left(searchArr)
			if j == len(ol):
				break
			(val, idx) = ol.pop(j)
			stoppingTrack[idx] = i
		ol.add([a[i], i])
	currMin = inf
	for i in range(2 * n - 1, -1, -1):
		stoppingTrack[i] = min(stoppingTrack[i], currMin)
		currMin = min(stoppingTrack[i], currMin)
	if stoppingTrack[0] == inf and len(set(stoppingTrack)) == 1:
		oneLineArrayPrint([-1] * n)
		return
	for i in range(n):
		if stoppingTrack[i] != inf:
			firstNonInf = stoppingTrack[i]
			break
	for i in range(n, 2 * n):
		if stoppingTrack[i] == inf:
			stoppingTrack[i] = 2 * n + firstNonInf
	ans = [-1] * n
	for i in range(n):
		res = min(stoppingTrack[i] - i, stoppingTrack[i + n] - (i + n))
		if res == inf:
			continue
		ans[i] = res
	if ans[0] == inf and len(set(ans)) == 1:
		oneLineArrayPrint([-1] * n)
	else:
		oneLineArrayPrint(ans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(t, i, j, x):
	print('? {} {} {} {}'.format(t, i, j, x))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(' '.join((str(x) for x in ans))))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


import sys
readline = sys.stdin.readline

class Segtree:

	def __init__(self, A, intv, initialize=True, segf=max):
		self.N = len(A)
		self.N0 = 2 ** (self.N - 1).bit_length()
		self.intv = intv
		self.segf = segf
		if initialize:
			self.data = [intv] * self.N0 + A + [intv] * (self.N0 - self.N)
			for i in range(self.N0 - 1, 0, -1):
				self.data[i] = self.segf(self.data[2 * i], self.data[2 * i + 1])
		else:
			self.data = [intv] * (2 * self.N0)

	def update(self, k, x):
		k += self.N0
		self.data[k] = x
		while k > 0:
			k = k >> 1
			self.data[k] = self.segf(self.data[2 * k], self.data[2 * k + 1])

	def query(self, l, r):
		(L, R) = (l + self.N0, r + self.N0)
		s = self.intv
		while L < R:
			if R & 1:
				R -= 1
				s = self.segf(s, self.data[R])
			if L & 1:
				s = self.segf(s, self.data[L])
				L += 1
			L >>= 1
			R >>= 1
		return s

	def binsearch(self, l, r, check, reverse=False):
		(L, R) = (l + self.N0, r + self.N0)
		(SL, SR) = ([], [])
		while L < R:
			if R & 1:
				R -= 1
				SR.append(R)
			if L & 1:
				SL.append(L)
				L += 1
			L >>= 1
			R >>= 1
		if reverse:
			for idx in SR + SL[::-1]:
				if check(self.data[idx]):
					break
			else:
				return -1
			while idx < self.N0:
				if check(self.data[2 * idx + 1]):
					idx = 2 * idx + 1
				else:
					idx = 2 * idx
			return idx
		else:
			for idx in SL + SR[::-1]:
				if check(self.data[idx]):
					break
			else:
				return -1
			while idx < self.N0:
				if check(self.data[2 * idx]):
					idx = 2 * idx
				else:
					idx = 2 * idx + 1
			return idx - self.N0
N = int(readline())
A = list(map(int, readline().split()))
B = [2 * a for a in A]
B *= 3
inf = 2 * 10 ** 9
B.append(-2)
T = Segtree(B, inf, True, min)
NN = T.N0
J = [0] * (NN + 1)
J[3 * N] = inf
KK = [None] * (NN + 1)
for i in range(3 * N - 1, -1, -1):
	a = A[i % N]
	k = T.binsearch(i, NN, lambda x: x < a, reverse=False)
	KK[i] = k
	J[i] = min(J[i + 1], k)
Ans = [-1] * N
for i in range(N):
	j = J[i]
	if j == 3 * N:
		continue
	Ans[i] = j - i
print(*Ans)


q = []
a = []
lnt = []
n = int(input())
a = map(int, input().split())
mx = 0
a = list(a)
for i in range(0, n):
	if a[i] > a[mx]:
		mx = i
	lnt.append(0)

def find_length(pos):
	for i in range(0, n):
		if a[(pos + i) % n] < a[pos] / 2:
			return i
	return -1

def q_add(index):
	if len(q) == 0:
		q.append(index)
		return
	while len(q) != 0 and a[index] <= a[q[len(q) - 1]]:
		q.pop()
	q.append(index)

def q_check():
	tm = -1
	while a[q[len(q) - 1]] > 2 * a[q[0]]:
		tm = q.pop(0)
	return tm
lnt[mx] = find_length(mx)
cm = lnt[mx]
q_add(mx)
for j in range(0, n):
	q_add((mx - j - 1 + n) % n)
	tm = q_check()
	if tm == -1:
		lnt[(mx - j - 1 + n) % n] = 1 + lnt[(mx - j + n) % n]
	else:
		lnt[(mx - j - 1 + n) % n] = (tm - (mx - j - 1 + n) % n + 2 * n) % n
if find_length(mx) == -1:
	for i in range(0, n):
		lnt[i] = -1
for i in range(n):
	print(lnt[i])


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import deque

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def val():
	return int(input().rstrip('\n'))

def st():
	return input().rstrip('\n')

def sttoli():
	return [int(i) for i in input().rstrip('\n')]
d = deque()
n = val()
l = li()
j = x = 0
currmax = -10000000000000
ans = []
for i in range(n):
	while len(d) and d[0] < i:
		d.popleft()
	currmax = l[d[0] % n] if len(d) else l[i]
	while j < 3 * n:
		currmax = max(currmax, l[j % n])
		while len(d) and l[d[-1] % n] <= l[j % n]:
			d.pop()
		d.append(j)
		if currmax / 2 > l[j % n]:
			ans.append(j - i)
			break
		j += 1
	if j == 3 * n:
		print(*[-1 for _______ in range(n)])
		exit()
print(*ans)


import heapq

def main():
	n = int(input())
	a = readIntArr()
	a = a + a + a
	maxHeap = []
	stoppingTrack = [inf] * (3 * n)
	for i in range(3 * n):
		searchVal = 2 * a[i] + 1
		while maxHeap and -maxHeap[0][0] >= searchVal:
			(val, idx) = heapq.heappop(maxHeap)
			stoppingTrack[idx] = i
		heapq.heappush(maxHeap, [-a[i], i])
	currMin = inf
	for i in range(3 * n - 1, -1, -1):
		stoppingTrack[i] = min(stoppingTrack[i], currMin)
		currMin = min(stoppingTrack[i], currMin)
	ans = [-1] * n
	for i in range(n):
		res = min(stoppingTrack[i] - i, stoppingTrack[i + n] - (i + n), stoppingTrack[i + 2 * n] - (i + 2 * n))
		if res == inf:
			continue
		ans[i] = res
	if ans[0] == inf and len(set(ans)) == 1:
		oneLineArrayPrint([-1] * n)
	else:
		oneLineArrayPrint(ans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(t, i, j, x):
	print('? {} {} {} {}'.format(t, i, j, x))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(' '.join((str(x) for x in ans))))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


def solve(n, a):
	c = [-1] * n
	start = find_max(n, a)
	c[start] = find_answer(start, n, a)
	if c[start] == -1:
		return c
	killer_pos = [-1] * n
	killer_head = 0
	killer_tail = 0
	for i in range(n - 1):
		j = (start - 1 - i + n) % n
		c[j] = c[(j + 1) % n] + 1
		while killer_tail + 1 < killer_head and a[killer_pos[killer_tail + 1]] * 2 < a[j]:
			killer_tail = killer_tail + 1
		if killer_tail < killer_head and a[killer_pos[killer_tail]] * 2 < a[j]:
			c[j] = min(c[j], (killer_pos[killer_tail] - j + n) % n)
		while killer_head - 1 >= killer_tail and a[killer_pos[killer_head - 1]] >= a[j]:
			killer_head = killer_head - 1
		killer_pos[killer_head] = j
		killer_head = killer_head + 1
	return c

def find_answer(start, n, a):
	x = 0
	for i in range(n):
		j = (start + i) % n
		if x > 2 * a[j]:
			return i
		if x < a[j]:
			x = a[j]
	return -1

def find_max(n, a):
	maxi = 0
	maxv = a[0]
	for i in range(n):
		if maxv < a[i]:
			maxv = a[i]
			maxi = i
	return maxi

def main():
	n = int(input())
	a = [int(s) for s in input().split()]
	c = solve(n, a)
	for i in range(n):
		print(c[i])
main()


import sys
input = sys.stdin.buffer.readline
from collections import deque
n = int(input())
l = list(map(int, input().split()))
d = deque()
ans = []
currmax = -1000000000000
j = 0
for i in range(n):
	while len(d) and d[0] < i:
		d.popleft()
	currmax = l[d[0] % n] if len(d) else l[i]
	while j < 3 * n:
		currmax = max(currmax, l[j % n])
		while d and l[d[-1] % n] <= l[j % n]:
			d.pop()
		d.append(j)
		if currmax / 2 > l[j % n]:
			ans.append(j - i)
			break
		j += 1
	if j == 3 * n:
		ans = [-1 for k in range(n)]
		print(*ans)
		exit()
	i += 1
print(*ans)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import *

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def val():
	return int(input().rstrip('\n'))

def st():
	return input().rstrip('\n')

def sttoli():
	return [int(i) for i in input().rstrip('\n')]

def notinarun(a, b, c):
	(x0, x1, y0, y1, z0, z1) = (min(a[0], b[0]), max(a[0], b[0]), min(a[1], b[1]), max(a[1], b[1]), min(a[2], b[2]), max(a[2], b[2]))
	if x0 <= c[0] <= x1 and y0 <= c[1] <= y1 and (z0 <= c[2] <= z1):
		return False
	return True
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import deque

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def val():
	return int(input().rstrip('\n'))

def st():
	return input().rstrip('\n')

def sttoli():
	return [int(i) for i in input().rstrip('\n')]
d = deque()
n = val()
l = li()
j = x = 0
currmax = -10000000000000
ans = []
for i in range(n):
	while len(d) and d[0] < i:
		d.popleft()
	currmax = l[d[0] % n] if len(d) else l[i]
	if len(d) and l[i] >= l[i - 1]:
		ans.append(ans[-1] - 1)
		continue
	while j < 3 * n:
		currmax = max(currmax, l[j % n])
		while len(d) and l[d[-1] % n] <= l[j % n]:
			d.pop()
		d.append(j)
		if currmax / 2 > l[j % n]:
			ans.append(j - i)
			break
		j += 1
	if j == 3 * n:
		print(*[-1 for _______ in range(n)])
		exit()
print(*ans)


NN = 18
MI = [1 << 100] * ((1 << NN + 1) - 1)

def update(x):
	i = (1 << NN) - 1 + x
	MI[i] = x
	while True:
		i = (i - 1) // 2
		MI[i] = min(MI[2 * i + 1], MI[2 * i + 2])
		if i == 0:
			break

def rangemin(a, b):
	l = a + (1 << NN)
	r = b + (1 << NN)
	mi = 1 << 100
	while l < r:
		if l % 2:
			mi = min(mi, MI[l - 1])
			l += 1
		if r % 2:
			r -= 1
			mi = min(mi, MI[r - 1])
		l >>= 1
		r >>= 1
	return mi
N = int(input())
A = [int(a) for a in input().split()]
B = sorted([(A[i], i) for i in range(N)])
i = 0
j = 0
X = [1 << 20] * (2 * N)
while i < N:
	while 2 * B[j][0] < B[i][0]:
		update(B[j][1])
		update(B[j][1] + N)
		j += 1
	X[B[i][1]] = rangemin(B[i][1], B[i][1] + N)
	X[B[i][1] + N] = X[B[i][1]] + N
	i += 1
for i in range(2 * N - 1)[::-1]:
	X[i] = min(X[i], X[i + 1])
for i in range(N):
	X[i] -= i
X = [a if a < 1 << 20 else -1 for a in X[:N]]
print(*X)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 30, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
n = int(input())
l = list(map(int, input().split()))
if max(l) <= 2 * min(l):
	print(*[-1] * n)
	sys.exit(0)
ind = [i for i in range(n)]
ind = sort_list(ind, l)
e = l + []
l += l
s1 = SegmentTree(l)
s = SegmentTree1(l)
small = [0] * n
large = [0] * n
for i in range(n):
	st = i + 1
	end = i + n
	small[i] = end
	while st <= end:
		mid = (st + end) // 2
		if s.query(st, mid) < l[i] / 2:
			small[i] = mid
			end = mid - 1
		else:
			st = mid + 1
	st = i + 1
	end = i + n
	large[i] = end
	while st <= end:
		mid = (st + end) // 2
		if s1.query(st, mid) > l[i]:
			large[i] = mid
			end = mid - 1
		else:
			st = mid + 1
e.sort()
ans = [0] * n
for i1 in range(n - 1, -1, -1):
	i = ind[i1]
	if small[i] < large[i]:
		ans[i] = small[i] - i
	else:
		ans[i] = ans[large[i] % n] + large[i] - i
print(*ans)


from sys import setrecursionlimit as SRL, stdin
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
n = int(input())
a = list(rrd())
a = [0] + a + a + a
bit = [10 ** 10] * 300005

def add(i, x):
	while i <= 3 * n + 1:
		bit[i] = min(bit[i], x)
		i += i & -i

def query(x):
	ans = 10 ** 10
	while x:
		ans = min(ans, bit[x])
		x -= x & -x
	return ans
ans = [0] * 300005
ans[3 * n + 1] = 3 * n + 1
from collections import deque
p = deque()
for i in range(3 * n, 0, -1):
	x = a[i]
	while len(p) and p[0][0] <= x:
		p.popleft()
	pos = p[0][1] if p else 3 * n + 1
	p.appendleft([x, i])
	r = pos
	if query(r) * 2 >= x:
		ans[i] = ans[r]
		add(i, x)
		continue
	l = i
	while l < r:
		m = (l + r) // 2
		if query(m) * 2 < x:
			r = m
		else:
			l = m + 1
	ans[i] = r
	add(i, x)
for i in range(1, n + 1):
	if ans[i] == 3 * n + 1:
		print(-1, end=' ')
	else:
		print(ans[i] - i, end=' ')