INF = 10 ** 18

N, A, B, C = map(int,input().split())
ls = [int(input()) for i in range(N)]

def func(pos, a, b, c):return abs(a - A) + abs(b - B) + abs(c - C) - 30 + INF * max(0, 1 - a * b * c) if pos == N else min(func(pos + 1, a + ls[pos] * (i == 0), b + ls[pos] * (i == 1), c + ls[pos] * (i == 2)) + 10 * (i < 3) for i in range(4))
print(func(0, 0, 0, 0))