n,x,*a=list(map(int,open(0).read().split()))

y=sum(a)

z=abs(x-y)

for i in a[:-1]:x+=i;y-=i;z=min(z,abs(x-y))

print(z)
n,x,*a,b=list(map(int,open(0).read().split()))

y=sum(a)+b

z=abs(x-y)

for i in a:x+=i;y-=i;z=min(z,abs(x-y))

print(z)
n, x, *a = list(map(int, open(0).read().split()))
y = sum(a)
z = abs(x - y)
for i in a[:-1]:
    x += i
    y -= i
    z = min(z, abs(x - y))
print(z)

n, x, *a, b = list(map(int, open(0).read().split()))
y = sum(a) + b
z = abs(x - y)
for i in a:
    x += i
    y -= i
    z = min(z, abs(x - y))
print(z)

-n, x, *a = list(map(int, open(0).read().split())) -y = sum(a) +n, x, *a, b = list(map(int, open(0).read().split())) +y = sum(a) + b -for i in a[:-1]: +for i in a: