CodeEff/ECCO huggingface dataset:
# Original solution
r, g, b = input().split()
num = int(r + g + b)
print(("YES" if num%4==0 else 'NO'))

# Optimized solution
r,g,b = input().split()
print(('YES' if int(r+g+b)%4==0 else 'NO'))
# Original solution
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    r,g,b = LI()
    s = r*100+g*10+b
    if s%4 == 0:
        print("YES")
    else:
        print("NO")
    return

#Solve
if __name__ == "__main__":
    solve()


# Optimized solution
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    r,g,b = LI()
    ans = ["YES","NO"]
    print((ans[((g<<1)+b)&3>0]))
    return

#Solve
if __name__ == "__main__":
    solve()
# Original solution
r, g, b = list(map(int, input().split()))
print(('YES' if (10 * g + b) % 4 == 0 else 'NO'))

# Optimized solution
r, g, b = list(map(int, input().split()))
number = 100 * r + 10 * g + b
if number % 4 == 0:
  print('YES')
else:
  print('NO')
# Original solution
r, g, b = input().split()
string = r + g + b
num = int(string)
if num % 4 == 0:
    print("YES")
else:
    print("NO")

# Optimized solution
r, g, b = input().split()
if int(r + g + b) % 4 == 0:
    print("YES")
else:
    print("NO")
# Original solution
r, g, b = list(map(int, input().split()))

if (10 * g + b) % 4 == 0:
    print("YES")
else:
    print("NO")


# Optimized solution
r, g, b = list(map(int, input().split()))

print(("YES" if (10 * g + b) % 4 == 0 else "NO"))
# Original solution
r, g, b = list(map(int, input().split()))

print(("YES" if (10 * g + b) % 4 == 0 else "NO"))


# Optimized solution
r, g, b = list(map(int, input().split(' ')))
print(('YES' if (10 * g + b) % 4 == 0 else'NO'))
# Original solution
r,g,b=list(map(int,input().split()))
result = (r*100+g*10+b)%4
if result==0:
  print('YES')
else:
  print('NO')

# Optimized solution
r,g,b=list(map(int,input().split()))
print(('YES' if (r*100+g*10+b)%4 == 0 else 'NO'))
# Original solution
r, g, b = input().split()
x = int(r + g + b)
if(x%4 == 0):
  print("YES")
else:
  print("NO")


# Optimized solution
r, g, b = input().split()
rgb = int(r + g + b)
if(rgb%4 == 0):
  print('YES')
else:
  print('NO')
# Original solution
r, g, b = list(map(int, input().split(" ")))
n = r * 100 + g * 10 + b
if n % 4 == 0:
  print("YES")
else:
  print("NO")

# Optimized solution
n = int("".join(input().split()))
if n % 4 == 0:
    print("YES")
else:
    print("NO")
# Original solution
a,b,c=list(map(int,input().split()))
print('YES') if (100*a+10*b+c)%4==0 else print('NO')


# Optimized solution
a,b,c=map(int,input().split())
print('YES') if (10*b+c)%4==0 else print('NO')
# Original solution
#ABC064 A - RGB Cards
si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))
r,g,b = list(map(str, input().split()))
s = r+g+b
if int(s)%4==0:
    print('YES')
else:
    print('NO')



# Optimized solution
r,g,b=list(map(str,input().split()))
ans=r+g+b
s=int(ans)

if s%4==0:
    print('YES')
else:
    print('NO')
# Original solution
print(("YES" if int(input().replace(" ", "")) % 4 == 0 else "NO"))

# Optimized solution
print(("NO" if int("".join(input().split())) % 4 else "YES"))
# Original solution
r, g, b = list(map(int, input().split()))
n = r*100 + g*10 + b
if n%4 == 0:
    print("YES")
else:
    print("NO")

# Optimized solution
n = "".join(input().split())

if int(n)%4 == 0:
    print("YES")
else:
    print("NO")
# Original solution
def main():
    A = int(eval(input()))
    B = int(eval(input()))

    if A > B:
        print("GREATER")
    elif A < B:
        print("LESS")
    else:
        print("EQUAL")


if __name__ == "__main__":
    main()

# Optimized solution
a=int(eval(input()));b=int(eval(input()))
print((["GREATER","EQUAL","LESS"][(a<b)+(a<=b)]))
# Original solution
import math

A = int(eval(input()))
B = int(eval(input()))
A = math.log10(A)
B = math.log10(B)

if A > B:
    print('GREATER')
elif A < B:
    print('LESS')
else:
    print('EQUAL')


# Optimized solution
import math

A = int(eval(input()))
B = int(eval(input()))
#A = math.log10(A)
#B = math.log10(B)

if A > B:
    print('GREATER')
elif A < B:
    print('LESS')
else:
    print('EQUAL')
# Original solution
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a = int(eval(input()))
    b = int(eval(input()))

    if a == b:
        print("EQUAL")
    elif a > b:
        print("GREATER")
    else:
        print("LESS")

if __name__=="__main__":
    main()

# Optimized solution
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a = int(eval(input()))
    b = int(eval(input()))

    if a > b :
        print("GREATER")
    elif a  < b :
        print("LESS")
    elif a  == b :
        print("EQUAL")

if __name__=="__main__":
    main()
# Original solution
import math
a = int(eval(input()))
b = int(eval(input()))
a = math.log10(a)
b = math.log10(b)
if a > b :
    print("GREATER")
elif a == b :
    print("EQUAL")
else :
    print("LESS")


# Optimized solution
import math
a = int(eval(input()))
b = int(eval(input()))
if a > b :
    print("GREATER")
elif a == b :
    print("EQUAL")
else :
    print("LESS")
# Original solution
a=int(eval(input()))-int(eval(input()));print((a>0 and'GREATER'or a<0 and'LESS'or'EQUAL'))

# Optimized solution
a=eval(input());b=eval(input());print(a<b and'LESS'or a>b and'GREATER'or'EQUAL')
# Original solution
a=int(eval(input()))-int(eval(input()));print((a>0and'GREATER'or a<0and'LESS'or'EQUAL'))

# Optimized solution
a=int(eval(input()))-int(eval(input()));print((a>0and'GREATER'or a and'LESS'or'EQUAL'))
# Original solution
a=int(eval(input()))
b=int(eval(input()))
print(("GREATER" if a>b else "LESS" if a<b else "EQUAL"))

# Optimized solution
A = int(eval(input()))
B = int(eval(input()))
print(("GREATER" if A > B else "LESS" if A < B else "EQUAL"))
# Original solution
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = int(sys.stdin.buffer.readline().rstrip())
    B = int(sys.stdin.buffer.readline().rstrip())
    print(('GREATER' if A > B else 'LESS' if A < B else 'EQUAL'))


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = ii()
    B = ii()
    print(('GREATER' if A > B else 'LESS' if A < B else 'EQUAL'))


if __name__ == '__main__':
    main()
# Original solution
A = int(eval(input()))
B = int(eval(input()))
if A>B:
    print("GREATER")
elif A<B:
    print("LESS")
else:
    print("EQUAL")

# Optimized solution
A = input().strip()
B = input().strip()
if len(A)>len(B):
    print("GREATER")
elif len(A)<len(B):
    print("LESS")
else:
    if A<B:
        print("LESS")
    elif A>B:
        print("GREATER")
    else:
        print("EQUAL")
# Original solution
a=input()
b=input()
if len(a)<len(b):
	print("LESS")
elif len(a)>len(b):
	print("GREATER")
else:
	p=0
	flag=True
	while flag:
		if a[p]<b[p]:
			print("LESS")
			flag=False
		elif a[p]>b[p]:
			print("GREATER")
			flag=False
		else:
			pass


# Optimized solution
a=int(input())
b=int(input())
if a<b:
	print("LESS")
elif a>b:
	print("GREATER")
else:
	print("EQUAL")
# Original solution
#abc59 b
a=int(eval(input()))
b=int(eval(input()))
if a>b:
    print("GREATER")
elif a<b:
    print("LESS")
else:
    print("EQUAL")

# Optimized solution
a=int(eval(input()))
b=int(eval(input()))

if a==b:
    print("EQUAL")
elif a>b:
    print("GREATER")
else:
    print("LESS")
# Original solution
A,B = int(eval(input())),int(eval(input()))
if A > B:
    print('GREATER')
elif A < B:
    print('LESS')
else:
    print('EQUAL')


# Optimized solution
A = int(eval(input()))
B = int(eval(input()))
if A>B:
    print('GREATER')
elif A==B:
    print('EQUAL')
else:
    print('LESS')
# Original solution
A=int(eval(input()))
B=int(eval(input()))
if A>B:
  print('GREATER')
elif A<B:
  print('LESS')
else:
  print('EQUAL')

# Optimized solution
A=int(eval(input()))
B=int(eval(input()))
print(('GREATER'if A>B else'LESS'if A<B else'EQUAL'))
# Original solution
a=int(eval(input()))
b=int(eval(input()))
print(("GREATER" if a>b else "LESS" if b>a else "EQUAL"))


# Optimized solution
a=int(eval(input()))
b=int(eval(input()))
if a>b:
  print("GREATER")
elif b>a:
  print("LESS")
else:
  print("EQUAL")
# Original solution
# seishin.py
N = int(eval(input()))
*P, = list(map(int, input().split()))
MOD = 10**9 + 7

G = [[] for i in range(N+1)]
for i, p in enumerate(P):
    G[p].append(i+1)
Q = [None]*(N+1)
for i in range(N, -1, -1):

    # 子ノードのqueを集める
    R = None
    for j in G[i]:
        S = Q[j]
        if not R:
            R = S
            continue

        # |R| > |S|
        if len(R) < len(S):
            R, S = S, R

        # queの小さい方から大きい方へマージする処理
        for s, r in zip(S, R):
            a0, a1, a2, c0 = s
            b0, b1, b2, c1 = r
            r[:] = a0*b0 % MOD, (a0*b1 + a1*b0) % MOD, (a2*(b0 + b1 + b2) + (a0 + a1)*b2 + a1*b1) % MOD, c0+c1
    if R:
        # a0 <- a2
        for e in R:
            e[0] += e[2]
            e[2] = 0

        Q[i] = [[1, 1, 0, 1]] + R
    else:
        Q[i] = [[1, 1, 0, 1]]
ans = 0
for a0, a1, a2, c in Q[0]:
    ans += pow(2, N+1-c, MOD) * a1 % MOD
print((ans % MOD))


# Optimized solution
# seishin.py
import sys
sys.setrecursionlimit(10**6)
N = int(eval(input()))
*P, = list(map(int, input().split()))
MOD = 10**9 + 7
from itertools import tee

G = [[] for i in range(N+1)]
for i, p in enumerate(P):
    G[p].append(i+1)
Q = [None]*(N+1)
E = [1, 1, 0, 1]
for i in range(N, -1, -1):
    def gen(i):
        *I, = list(map(Q.__getitem__, G[i]))
        r = E
        while r:
            a,b,c,d=r
            yield (a+c,b,0,d)
            r = None
            for it in I:
                s = next(it, None)
                if s:
                    if r:
                        a0, a1, a2, c0 = s
                        b0, b1, b2, c1 = r
                        r = a0*b0 % MOD, (a0*b1 + a1*b0) % MOD, ((a0 + a1)*b2 + a1*b1) % MOD, c0+c1
                    else:
                        r = s
    Q[i] = gen(i)
ans = 0
for a0, a1, a2, c in Q[0]:
    ans += pow(2, N+1-c, MOD) * a1 % MOD
print((ans % MOD))
# Original solution
# seishin.py
from collections import deque
N = int(eval(input()))
*P, = list(map(int, input().split()))
MOD = 10**9 + 7

G = [[] for i in range(N+1)]
U = [0]*(N+1)
C = [0]*(N+1)
for i, p in enumerate(P):
    G[p].append(i+1)
    U[i+1] = u = U[p]+1
    C[u] += 1
Q = [None]*(N+1)
PP = {}
def pp(k):
    if k not in PP:
        PP[k] = p = pow(2, k, MOD)
        return p
    return PP[k]
L = [0]*(N+1)

sz = L.__getitem__
for i in range(N, -1, -1):
    g = G[i]
    if not g:
        continue

    # 子ノードのdequeを集める
    g.sort(key=sz, reverse=1)
    k = len(g)
    e = [pp(k) - k, k, 0]

    g0 = g[0]
    L[i] = L[g0] + 1
    if L[g0] == 0:
        Q[i] = deque([e])
        continue
    Q[i] = R = Q[g0]
    for j in g[1:]:
        S = Q[j]
        if not S:
            break

        # dequeの小さい方から大きい方へマージする処理
        for (a0, a1, a2), r in zip(S, R):
            b0, b1, b2 = r
            r[0] = a0*b0 % MOD
            r[1] = (a0*b1 + a1*b0) % MOD
            r[2] = ((a0+a1)*b2 + a1*b1) % MOD

    # a0 <- a2
    for r in R:
        r[0] += r[2]
        r[2] = 0
    R.appendleft(e)
print(((pp(N) + sum(pp(N+1-c) * a1 % MOD for (a0, a1, a2), c in zip(Q[0], C[1:]))) % MOD))

# Optimized solution
# seishin.py
from collections import deque
N = int(eval(input()))
*P, = list(map(int, input().split()))
MOD = 10**9 + 7

G = [[] for i in range(N+1)]
U = [0]*(N+1)
C = [0]*(N+1)
for i, p in enumerate(P):
    G[p].append(i+1)
    U[i+1] = u = U[p]+1
    C[u] += 1
Q = [None]*(N+1)
PP = {}
def pp(k):
    if k not in PP:
        PP[k] = p = pow(2, k, MOD)
        return p
    return PP[k]
L = [0]*(N+1)

ept = []
sz = L.__getitem__
for i in range(N, -1, -1):
    g = G[i]
    if not g:
        continue

    # 子ノードのdequeを集める
    g.sort(key=sz, reverse=1)
    k = len(g)
    e = [pp(k) - k, k, 0]

    g0 = g[0]
    L[i] = L[g0] + 1
    if L[g0] == 0:
        Q[i] = deque([e])
        continue
    Q[i] = R = Q[g0]
    if k > 1:
        # a0 <- a2
        for s, r in zip(Q[g[1]] or ept, R):
            r[0] += r[2]; r[2] = 0

        for j in g[1:]:
            S = Q[j]
            if not S:
                break

            # dequeの小さい方から大きい方へマージする処理
            for (a0, a1, a2), r in zip(S, R):
                b0, b1, b2 = r; a0 += a2
                r[0] = a0*b0 % MOD
                r[1] = (a0*b1 + a1*b0) % MOD
                r[2] = ((a0+a1)*b2 + a1*b1) % MOD
    R.appendleft(e)
print(((pp(N) + sum(pp(N+1-c) * a1 % MOD for (a0, a1, a2), c in zip(Q[0], C[1:]))) % MOD))
# Original solution
mod = 1000000007


def get_pow():
    cache = {}

    def func(x):
        if x not in cache:
            cache[x] = pow(2, x, mod)
        return cache[x]

    return func


n = int(eval(input()))
parents = list(map(int, input().split()))
children = [set() for _ in range(n + 1)]
for c, p in enumerate(parents):
    children[p].add(c + 1)

levels = [{0}]
while True:
    level = set()
    for p in levels[-1]:
        level.update(children[p])
    if not level:
        break
    levels.append(level)
levels.reverse()

level_node_count = []
balls = [None] * (n + 1)

for i, level in enumerate(levels):
    level_node_count.append(len(level))
    for node in level:
        if children[node]:
            balls_from_children = [balls[c] for c in children[node]]
            balls_from_children.sort(key=len)
            for bs1, bs2 in zip(balls_from_children, balls_from_children[1:]):
                for b1, b2 in zip(bs1, bs2):
                    b2[2] = (b1[1] + b1[2]) * b2[1] + b1[2] * b2[0]
                    b2[1] = b1[0] * b2[1] + b1[1] * b2[0]
                    b2[0] *= b1[0]
            for b in balls_from_children[-1]:
                b[0] += b[2]
                b[2] = 0
            balls[node] = [[1, 1, 0]] + balls_from_children[-1]
        else:
            balls[node] = [[1, 1, 0]]

level_node_count.reverse()

pow2 = get_pow()
print((sum(b[1] * pow2(n - l + 1) for l, b in zip(level_node_count, balls[0])) % mod))


# Optimized solution
def get_pow():
    cache = {}

    def func(x):
        if x not in cache:
            cache[x] = pow(2, x, mod)
        return cache[x]

    return func


mod = 1000000007
n = int(eval(input()))
parents = list(map(int, input().split()))
children = [set() for _ in range(n + 1)]
for c, p in enumerate(parents):
    children[p].add(c + 1)

levels = [{0}]
while True:
    level = set()
    for p in levels[-1]:
        level.update(children[p])
    if not level:
        break
    levels.append(level)
levels.reverse()

level_node_count = []
balls = [None] * (n + 1)

for i, level in enumerate(levels):
    level_node_count.append(len(level))
    for node in level:
        balls[node] = [[1, 1, 0]]
        if children[node]:
            balls_from_children = [balls[c] for c in children[node]]
            balls_from_children.sort(key=len)
            for bs1, bs2 in zip(balls_from_children, balls_from_children[1:]):
                for (b10, b11, b12), b2 in zip(bs1, bs2):
                    b2[2] = ((b11 + b12) * b2[1] + b12 * b2[0]) % mod
                    b2[1] = (b10 * b2[1] + b11 * b2[0]) % mod
                    b2[0] *= b10
            for b in balls_from_children[-1]:
                b[0] += b[2]
                b[2] = 0
            balls[node].extend(balls_from_children[-1])

level_node_count.reverse()

pow2 = get_pow()
print((sum(b[1] * pow2(n - l + 1) % mod for l, b in zip(level_node_count, balls[0])) % mod))
# Original solution
import sys
from collections import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    def dfs(u=0):
        def merge(dpu, dpv):
            vn = len(dpv)
            for d in range(-1, -1 - vn, -1):
                u0, u1, u2 = dpu[d]
                v0, v1, v2 = dpv[d]
                n0 = (u0 * v0) % md
                n1 = (u0 * v1 + u1 * v0) % md
                n2 = (u2 * (v0 + v1 + v2) + v2 * (u0 + u1) + u1 * v1) % md
                dpu[d] = (n0, n1, n2)

        dpu = deque()
        start=(inv2, inv2, 0)
        # 葉の場合
        if len(to[u]) == 0:
            dpu.append(start)
            return dpu
        # すべての子をマージ
        for v in to[u]:
            dpv = dfs(v)
            #深さが2段以上あったらu2をu0に
            if len(dpv) > 1:
                for d, (u0, u1, u2) in enumerate(dpv):
                    dpv[d] = (u0 + u2, u1, 0)
            if not dpu:
                dpu = dpv
            else:
                if len(dpu) < len(dpv): dpu, dpv = dpv, dpu
                merge(dpu, dpv)
        dpu.append((inv2, inv2, 0))
        return dpu

    md = 10 ** 9 + 7
    # 1/2のmod
    inv2 = pow(2, md - 2, md)
    to = defaultdict(list)
    n = int(input())
    pp = list(map(int, input().split()))
    for i, p in enumerate(pp, 1):
        to[p].append(i)
    # print(to)
    dp0 = dfs()
    # print(dp0)
    ans = sum(u1 for _, u1, _ in dp0)
    print((ans * pow(2, n + 1, md)) % md)

main()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    def dfs(u=0):
        def merge(dpu, dpv):
            vn = len(dpv)
            for d in range(-1, -1 - vn, -1):
                u0, u1, u2 = dpu[d]
                v0, v1, v2 = dpv[d]
                n0 = (u0 * v0) % md
                n1 = (u0 * v1 + u1 * v0) % md
                n2 = (u2 * (v0 + v1 + v2) + v2 * (u0 + u1) + u1 * v1) % md
                dpu[d] = (n0, n1, n2)

        # 葉の場合
        if len(to[u]) == 0:
            return [(inv2, inv2, 0)]
        # すべての子をマージ
        dpu = []
        mxlen=0
        for v in to[u]:
            dpv = dfs(v)
            #深さが2段以上あったらu2をu0に
            if not dpu:
                dpu = dpv
            else:
                if len(dpu) < len(dpv): dpu, dpv = dpv, dpu
                mxlen=max(mxlen,len(dpv))
                merge(dpu, dpv)
        for d in range(-1,-1-mxlen,-1):
            u0,u1,u2=dpu[d]
            dpu[d] = (u0 + u2, u1, 0)
        dpu.append((inv2, inv2, 0))
        return dpu

    md = 10 ** 9 + 7
    # 1/2のmod
    inv2 = pow(2, md - 2, md)
    n = int(input())
    to = [[] for _ in range(n+1)]
    pp = list(map(int, input().split()))
    for i, p in enumerate(pp, 1):
        to[p].append(i)
    # print(to)
    dp0 = dfs()
    # print(dp0)
    ans = sum(u1 for _, u1, _ in dp0)
    print((ans * pow(2, n + 1, md)) % md)

main()
# Original solution


def merge(p1, p2):
    inds = list(set(p1 + p2))
    inds.sort(key=lambda i: a[i],reverse=True)
    return inds[:2]


n = eval(input())
a = list(map(int, input().split()))
a.append(0) #default value used for a[-1]

best = a[0]
dp = [[i, -1] for i in range(1 << n)]
for mask in range(1, len(dp)):
    for j in range(n):
        if mask & (1 << j):
            dp[mask] = merge(dp[mask], dp[mask ^ (1 << j)])
    best = max(best, sum([a[x] for x in dp[mask]]))
    print(best)


# Optimized solution


def merge(a, b):
    if a[0] > b[0]:
        if a[1] > b[0]:
            return a
        return a[0], b[0]
    if b[1] > a[0]:
        return b
    return b[0], a[0]


n = eval(input())
a = list(map(int, input().split()))

dp = [(a[i], 0) for i in range(1 << n)]
for j in range(n):
    for mask in range(1, len(dp)):
        if mask & (1 << j):
            dp[mask] = merge(dp[mask], dp[mask ^ (1 << j)])

best = a[0]
for i in range(1, len(dp)):
    best = max(best, sum(dp[i]))
    print(best)
# Original solution
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Top2:
    def __init__(self,x=-1,y=-1):
        if x<y:x,y=y,x
        self.val=[x,y]
        self.s=x+y

    def __add__(self, other):
        self.val=sorted(self.val+other.val,reverse=True)[:2]
        return self

n=II()
aa=LI()
dp=[Top2(a) for a in aa]

for i in range(n):
    for j in range((1<<n)-1,-1,-1):
        if j>>i&1:continue
        dp[j|1<<i]+=dp[j]

mx=-1
for j in range(1,1<<n):
    mx=max(mx,sum(dp[j].val))
    print(mx)


# Optimized solution
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Top2:
    def __init__(self,x=-1,y=-1):
        if x<y:x,y=y,x
        self.val=[x,y]

    def __add__(self, other):
        self.val=sorted(self.val+other.val,reverse=True)[:2]
        return self

n=II()
aa=LI()
dp=[Top2(a) for a in aa]

for i in range(n):
    for j in range((1<<n)-1,-1,-1):
        if j>>i&1:continue
        dp[j|1<<i]+=dp[j]

mx=-1
for j in range(1,1<<n):
    mx=max(mx,sum(dp[j].val))
    print(mx)
# Original solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    d = [None]*(2**n)
    d[0] = [a[0], 0, -1, -1]
    ans = 0
    for i, t1 in enumerate(a[1:]):
        i += 1
        t2, t3, t4 = i, -1, -1
        for j in range(len(bin(i))-2):
            k = i & ~(1 << j)
            if k == i:
                continue
            t5, t6, t7, t8 = d[k]
            if t5 > t1:
                t1, t2, t3, t4 = t5, t6, t1, t2
            elif t5 > t3:
                if t6 != t2:
                    t3, t4 = t5, t6
            if t7 > t3:
                t3, t4 = t7, t8
        d[i] = [t1, t2, t3, t4]
        ans = max(ans, t1+t3)
        print(ans)


main()

# Optimized solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    d = [[j, i, -1, -1] for i, j in enumerate(a)]
    ans = 0
    for i in range(1, 2**n):
        t1, t2, t3, t4 = d[i]
        for j in range(len(bin(i))-2):
            t5, t6, t7, t8 = d[i & ~(1 << j)]
            if t5 > t1:
                t1, t2, t3, t4 = t5, t6, t1, t2
            elif t5 > t3:
                if t6 != t2:
                    t3, t4 = t5, t6
                    continue
            if t7 > t3:
                t3, t4 = t7, t8
        d[i] = [t1, t2, t3, t4]
        ans = max(ans, t1+t3)
        print(ans)


main()