Daniel is organizing a football tournament. He has come up with the following tournament format:   In the first several (possibly zero) stages, while the number of teams is even, they split in pairs and play one game for each pair. At each stage the loser of each pair is eliminated (there are no draws). Such stages are held while the number of teams is even.  Eventually there will be an odd number of teams remaining. If there is one team remaining, it will be declared the winner, and the tournament ends. Otherwise each of the remaining teams will play with each other remaining team once in round robin tournament (if there are x teams, there will be $\frac{x \cdot(x - 1)}{2}$ games), and the tournament ends. 

For example, if there were 20 teams initially, they would begin by playing 10 games. So, 10 teams would be eliminated, and the remaining 10 would play 5 games. Then the remaining 5 teams would play 10 games in a round robin tournament. In total there would be 10+5+10=25 games.

Daniel has already booked the stadium for n games. Help him to determine how many teams he should invite so that the tournament needs exactly n games. You should print all possible numbers of teams that will yield exactly n games in ascending order, or -1 if there are no such numbers.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 10^18), the number of games that should be played.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Output-----

Print all possible numbers of invited teams in ascending order, one per line. If exactly n games cannot be played, output one number: -1.


-----Examples-----
Input
3

Output
3
4

Input
25

Output
20

Input
2

Output
-1

Difficulty: interview

Starter code:

Solutions:
n = int(input())
res = set()
for r in range(100):
    a = 1
    b = 2**(r + 1) - 3
    c = -2 * n
    d = b * b - 4 * a * c
    if d < 0:
        continue
    le = 0
    ri = d
    while le < ri:
        c = (le + ri) // 2
        if c * c < d:
            le = c + 1
        else:
            ri = c
    if le * le == d:
        if (-b - le) % 4 == 2 and -b - le > 0:
            res.add((-b - le) // 2 * 2**r)
        if (-b + le) % 4 == 2 and -b + le > 0:
            res.add((-b + le) // 2 * 2**r)
for i in sorted(list(res)):
    print(i)
if not list(res):
    print(-1)


def calc(n):
    res = 0
    while n % 2 == 0:
        n //= 2
        res += n
    return res + n * (n - 1) // 2

def check(n, q):
    if 2 ** q - 1 > n:
        return None
    left = 0
    right = 10 ** 10
    f = lambda k : k * (k - 1) // 2 + k * (2 ** q - 1)
    while left + 1 < right:
        mid = (left + right) // 2
        if f(mid) <= n:
            left = mid
        else:
            right = mid
    count = left * 2**q
    if calc(count) == n:
        return count
    else:
        return None

n = int(input())

ans = set()

# We want n=k*(k-1)/2 + k*(2^q-1)
for q in range(0, 64):
    k = check(n, q)
    if k:
        ans.add(k)

if ans:
    for i in sorted(ans):
        assert calc(i) == n, "n=%d, i=%d"%(n, i)
        print(i)
else:
    print(-1)


n = int(input())

def f(k, p):
    p = 2 * p - 1
    return p * (2 ** k - 1) + p * (p - 1) // 2

ans = set()

for k in range(65):
    l = 0
    r = n + 2
    while l + 1 < r:
        m = (l + r) // 2
        if f(k, m) < n:
            l = m
        else:
            r = m
    if f(k, r) > n:
        continue
    while f(k, r + 1) == n:
        r += 1
    for i in range(l + 1, r + 1):
        ans.add(2 ** k * (2 * i - 1))
        
for x in sorted(ans):
    print(x)
    
if not ans:
    print(-1)


n = int(input())*2
def calc(d):
    mi, ma = 1, n
    md = 0
    while mi != ma:
        md = (mi + ma) // 2
        if md * (md + d) < n:
            mi = md+1
        else:
            ma = md
    return ma if ma*(ma+d) == n and ma%2 else -1


d = 1
li = []
while d <= n:
    d *= 2
    u = calc(d-3)
    if u != -1:
        li.append(u*d//2)
li.sort()
if (len(li)):
    for d in li:
        print(d)
else:
    print(-1)

3
y=int(input())
s=set()
e=1
for k in range(0,70):
	b=2*e-3
	c=-2*y
	d=b*b-4*c
	if d>=0:
		L=0
		R=d
		while True:
			M=(L+R+1)//2
			if L==R:
				break
			MM=M*M
			if MM>d:
				R=M-1
			else:
				L=M
		if M*M==d:
			x=-b+M
			if x>0 and x%2==0:
				x//=2
				if x%2==1:
					s.add(x*e)
			x=-b-M
			if x>0 and x%2==0:
				x//=2
				if x%2==1:
					s.add(x*e)
	e<<=1
y=True
for x in sorted(s):
	print(x)
	y=False
if y:
	print(-1)

n = int(input())
succ = False;
for ii in range(0, 100):
	i = 2 ** ii
	l = 1
	r = 2 ** 100
	while l < r:
		mid = (l+r)//2
		x = 2 * mid - 1
		v = x*((x-1)//2+i-1)
		if v == n:
			succ = True
			print(x*i)
			break
		elif v < n:
			l = mid + 1
		else:
			r = mid
if not succ:
	print("-1")


import math
from fractions import Decimal
from decimal import *
getcontext().prec = 100
x=Decimal(input())
def tows(n):
    ans=Decimal(0)
    while(n>0):
        ans+=Decimal(2**n)
        n-=1
    return ans
k=True
answer=[]
for n in range(100,-1,-1):
    d=tows(n)
    b=(d -1)
    ans=[]
    s=Decimal(Decimal(b**2)+Decimal(8*x))
    s=s.sqrt()
    h=Decimal(-b/2)
    ans.append(h + s/2)
    ans.append(h - s/2)
    for item in ans:
        if(item <1 or item%2!=1):
            continue
        answer.append(item*(2**(n)))
        k=False
if(k):
    print(-1)
answer.sort()
for item in answer:
    print(int(item))
    


def cc(res):
    l = 1
    r = res
    while l<=r:
        mid = l+r >>1
        if mid*mid==res:
            return mid
        elif mid*mid>res:
            r = mid-1
        else:
            l = mid+1
    return -1


def solve(a,b,c):
    if b*b-4*a*c<0:
        return -1
    r = cc(b*b-4*a*c)
    
    if r*r!=b*b-4*a*c:
        return -1
    
    r = -b+r
    if r%(2*a)!=0:
        return -1
    return int(r/2/a)


n = int(input())
tmp = []
for i in range(0,100):
    now = 1<<(i+1)
    ans = solve(1,now-3,-2*n)
    if ans!=-1 and ans%2==1:
        tmp.append( int(ans*now/2) )

tmp.sort()
pre = -1
for i in tmp:
    if i!=pre:
        print(i)
    pre = i
if pre ==-1:
    print(-1)



n = int(input())
f = 0

for p in range(63):
  N = 1 << (p+1)
  l = 0
  h = n
  while h >= l:
    m = (l+h)//2
    x = m*2+1
    res = x*(x+N-3)
    if res == n*2:
      print(x*(1 << p))
      f = 1
      break
    elif res > n*2:
      h = m-1
    else:
      l = m+1

if f==0:
  print(-1)


f=n=int(input())
N=1
while N<=n*2:
 l,h=0,n
 while h>=l:
  m=(l+h)//2
  r=(m*2+1)*(m+N-1)
  if r>n:h=m-1
  elif r<n:l=m+1
  else:
   print(m*2*N+N)
   f=0
   break
 N*=2
if f:print(-1)

n = int(input())

def f(t, k):
	return t*(t-1)//2 + t*((1<<k)-1)

ans = set()
for k in range(60):
	l = 0
	r = n
	p = 0
	while l <= r:
		t = (l+r)//2
		if f(t, k) <= n:
			p = t
			l = t+1
		else:
			r = t-1
	if p % 2 == 1 and f(p, k) == n:
		ans.add(p * (1<<k))

for x in sorted(ans):
	print(x)

if not ans:
	print(-1)

def f(x, k):
    return x * (x - 1) // 2 + ((2 ** k) - 1) * x

res = []
n = int(input())
for k in range(0, 64):
    l = 1
    r = 2 ** 100
    while l < r:
        m = (l + r) // 2
        cur = f(m, k)
        if cur < n:
            l = m + 1
        else:
            r = m
    if f(l, k) != n or l % 2 == 0:
        continue
    cand = (2 ** k) * l
    if not (cand in res):
        res.append(cand)
if len(res) == 0:
    res.append(-1)
for x in sorted(res):
    print(x)


N =int(input())

e =1
B =False
while True:
	a =1
	b =N+1
	if a*(a-3)//2+e*a > N: break
	while b-a > 1:
		c =(b+a)//2
		if e*c+c*(c-3)//2 <= N: a =c
		else: b =c
#	print(a)
	if (a%2 != 0) & (e*a+a*(a-3)//2 == N): 
		B =True
		print(a*e)
	e *=2
if B == False: print(-1)


n = int(input()) + 1
b, p = 1, []
while b < n + 1:
    d = (2 * b - 1) ** 2 + 8 * (n - b)
    s = int(d ** 0.5)
    s += int((d // s - s) // 2)
    if s * s == d:
        a = s - (2 * b - 1)
        if a % 4 == 0: p.append(b * (a // 2 + 1))
    b *= 2
print('\n'.join(map(str, p)) if p else '-1')

n = int(input())

def f(k, p):
    p = 2 * p - 1
    return p * (2 ** k - 1) + p * (p - 1) // 2

ans = set()

for k in range(65):
    l = 0
    r = n + 2
    while l + 1 < r:
        m = (l + r) // 2
        if f(k, m) < n:
            l = m
        else:
            r = m
    if f(k, r) > n:
        continue
    while f(k, r + 1) == n:
        r += 1
    for i in range(l + 1, r + 1):
        ans.add(2 ** k * (2 * i - 1))
        
for x in sorted(ans):
    print(x)
    
if not ans:
    print(-1)


f=n=int(input())
N=1
while N<=n*2:
 l,h=0,n
 while h>=l:
  m=(l+h)//2
  r=(m*2+1)*(m+N-1)
  if r>n:h=m-1
  elif r<n:l=m+1
  else:
   print(m*2*N+N)
   f=0
   break
 N*=2
if f:print(-1)

f=n=int(input())
N=1
while N<=n*2:
 l,h=0,n
 while h>=l:
  m=(l+h)//2
  r=(m*2+1)*(m+N-1)
  if r>n:h=m-1
  elif r<n:l=m+1
  else:
   print(m*2*N+N)
   f=0
   break
 N*=2
if f:print(-1)

from decimal import *

def is_int(d):
    return d == int(d)

getcontext().prec=40
n=Decimal(input())
l=[]
p2=Decimal(1)
for i in range(70):
	d=9+8*n+4*(p2**2)-12*p2
	x=(3-2*p2+d.sqrt())/2
	if(is_int(x)):
		if(x%2==1):
			l.append(p2*x)#l.append((p2+(x+1)/2)*x)
	p2=p2*2
l.sort()
if len(l)==0:
	print(-1)
else:
	for i in l:
		print(int(i))

n = int(input())
ans = []
for i in range(0, 64):
	y = 2 ** i
	deter = (y - 3) ** 2 + (4 * 2 * n)
	if deter >= 0:
		sqrt = int(pow(deter, .5))
		while(sqrt * sqrt < deter):
			sqrt += 1
		while(sqrt * sqrt > deter):
			sqrt -= 1
		if(sqrt * sqrt == deter):
			ev1 = 3 - y + sqrt
			if(ev1 % 2 == 0):
				ev1 /= 2
				if(ev1 > 0 and ev1 % 2 == 1):
					for j in range(0, i):
						ev1 *= 2
					ans.append(ev1 / 2);

			ev1 = 3 - y - sqrt
			if(ev1 % 2 == 0):
				ev1 /= 2
				if(ev1 > 0 and ev1 % 2 == 1):
					for j in range(0, i):
						ev1 *= 2
					ans.append(ev1 / 2);
for i in sorted(ans):
	print(int(i))
if not len(ans):
	print(-1)