おそろしい祭りだ。

solution

愚直にやって間に合う。$O(2^N)$。

implementation

#!/usr/bin/env python3
n = int(input())
a = [ int(input()) for _ in range(2**n) ]
while len(a) != 1:
    b = []
    for i in range(0, len(a), 2):
        if a[i] == a[i+1]:
            b += [ a[i] ]
        else:
            b += [ abs(a[i] - a[i+1]) ]
    a = b
print(*a)