import sys
input = sys.stdin.readline
n = int(input())
snow = list(map(int, input().split()))
snow.sort()
answer = sys.maxsize
for i in range(n):
for j in range(i + 3, n):
left, right = i + 1, j - 1
while left < right:
tmp = (snow[i] + snow[j]) - (snow[left] + snow[right])
if abs(answer) > abs(tmp):
answer = abs(tmp)
if tmp < 0:
right -= 1
else:
left += 1
print(answer)