N, A, B, C = [int(i) for i in input().split()]
L = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(2 ** (N * 2)):
    a = b = c = 0
    cnt = 0
    for j in range(N):
        bit = i & 3
        if bit == 1:
            a += L[j]
        elif bit == 2:
            b += L[j]
        elif bit == 3:
            c += L[j]
        if bit:
            cnt += 1
        i >>= 2
    if a and b and c:
        ans = min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c))
print(ans) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N, A, B, C = [int(i) for i in input().split()] N [int(i) for i in input().split()] A B C int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input L = [int(input()) for _ in range(N)] L [int(input()) for _ in range(N)] ans = float("inf") ans float("inf") float "inf" for i in range(2 ** (N * 2)):
    a = b = c = 0
    cnt = 0
    for j in range(N):
        bit = i & 3
        if bit == 1:
            a += L[j]
        elif bit == 2:
            b += L[j]
        elif bit == 3:
            c += L[j]
        if bit:
            cnt += 1
        i >>= 2
    if a and b and c:
        ans = min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c)) i range(2 ** (N * 2)) range 2 ** (N * 2) 2 N * 2 N 2 a = b = c = 0 a 0 = b = c = 0 b 0 c cnt = 0 cnt 0 for j in range(N):
        bit = i & 3
        if bit == 1:
            a += L[j]
        elif bit == 2:
            b += L[j]
        elif bit == 3:
            c += L[j]
        if bit:
            cnt += 1
        i >>= 2
     j range(N) range N bit = i & 3 bit i & 3 i 3 if bit == 1:
            a += L[j]
        elif bit == 2:
            b += L[j]
        elif bit == 3:
            c += L[j]
         bit == 1 bit 1 a += L[j] a L[j] L j elif bit == 2:
            b += L[j]
         bit == 2 bit 2 b += L[j] b L[j] L j elif bit == 3:
            c += L[j]
         bit == 3 bit 3 c += L[j] c L[j] L j if bit:
            cnt += 1
         bit cnt += 1 cnt 1 i >>= 2 i 2 if a and b and c:
        ans = min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c)) a and b and c a and b a b c ans = min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c)) ans min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c)) min ans (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c) (cnt - 3) * 10 + abs(A - a) + abs(B - b) (cnt - 3) * 10 + abs(A - a) (cnt - 3) * 10 cnt - 3 cnt 3 10 abs(A - a) abs A - a A a abs(B - b) abs B - b B b abs(C - c) abs C - c C c print(ans) print ans cnt += 1 1 cnt A, B, C = [int(i) for i in input().split()] [int(i) for i in input().split()] A N, A, B, C = [int(i) for i in input().split()] [int(i) for i in input().split()] N a = b = c = 0 0 a b = c = 0 0 b c = 0 0 c L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L ans = min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c)) min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c)) ans cnt = 0 0 cnt i >>= 2 2 i ans = float("inf") float("inf") ans a += L[j] L[j] a c += L[j] L[j] c bit = i & 3 i & 3 bit C = [int(i) for i in input().split()] [int(i) for i in input().split()] C b += L[j] L[j] b B, C = [int(i) for i in input().split()] [int(i) for i in input().split()] B
N, A, B, C = [int(i) for i in input().split()]
L = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(2 ** (N * 2)):
    a = b = c = 0
    cnt = 0
    for j in range(N):
        bit = i & 3
        if bit == 1:
            a += L[j]
        elif bit == 2:
            b += L[j]
        elif bit == 3:
            c += L[j]
        if bit:
            cnt += 1
        i >>= 2
    if a and b and c:
        ans = min(ans, (cnt - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c))
print(ans)