from itertools import product
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
INF = 10 ** 30
def calc(p):
    if sum(list(set(p))) < 6:
        return INF
    a, b, c = 0, 0, 0
    ac, bc, cc = 0, 0, 0
    for i, v in enumerate(p):
        if v == 1:
            a += L[i]
            ac += 1
        elif v == 2:
            b += L[i]
            bc += 1
        elif v == 3:
            c += L[i]
            cc += 1
    return abs(A-a) + abs(B-b) + abs(C-c) + (ac+bc+cc-3) * 10

ans = INF
for p in product(range(4), repeat=N):
    ans = min(ans, calc(p))
print(ans) from itertools import product N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input L = [int(input()) for i in range(N)] L [int(input()) for i in range(N)] INF = 10 ** 30 INF 10 ** 30 10 30 def calc(p):
    if sum(list(set(p))) < 6:
        return INF
    a, b, c = 0, 0, 0
    ac, bc, cc = 0, 0, 0
    for i, v in enumerate(p):
        if v == 1:
            a += L[i]
            ac += 1
        elif v == 2:
            b += L[i]
            bc += 1
        elif v == 3:
            c += L[i]
            cc += 1
    return abs(A-a) + abs(B-b) + abs(C-c) + (ac+bc+cc-3) * 10 calc if sum(list(set(p))) < 6:
        return INF
     sum(list(set(p))) < 6 sum(list(set(p))) sum list(set(p)) list set(p) set p 6 return INF INF a, b, c = 0, 0, 0 a 0 b 0 c 0 ac, bc, cc = 0, 0, 0 ac 0 bc 0 cc 0 for i, v in enumerate(p):
        if v == 1:
            a += L[i]
            ac += 1
        elif v == 2:
            b += L[i]
            bc += 1
        elif v == 3:
            c += L[i]
            cc += 1
     i v enumerate(p) enumerate p if v == 1:
            a += L[i]
            ac += 1
        elif v == 2:
            b += L[i]
            bc += 1
        elif v == 3:
            c += L[i]
            cc += 1
     v == 1 v 1 a += L[i] a L[i] L i ac += 1 ac 1 elif v == 2:
            b += L[i]
            bc += 1
         v == 2 v 2 b += L[i] b L[i] L i bc += 1 bc 1 elif v == 3:
            c += L[i]
            cc += 1
     v == 3 v 3 c += L[i] c L[i] L i cc += 1 cc 1 return abs(A-a) + abs(B-b) + abs(C-c) + (ac+bc+cc-3) * 10 abs(A-a) + abs(B-b) + abs(C-c) + (ac+bc+cc-3) * 10 abs(A-a) + abs(B-b) + abs(C-c) abs(A-a) + abs(B-b) abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c (ac+bc+cc-3) * 10 ac+bc+cc-3 ac+bc+cc ac+bc ac bc cc 3 10 p p ans = INF ans INF for p in product(range(4), repeat=N):
    ans = min(ans, calc(p)) p product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N ans = min(ans, calc(p)) ans min(ans, calc(p)) min ans calc(p) calc p print(ans) print ans A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C def calc(p):
    if sum(list(set(p))) < 6:
        return INF
    a, b, c = 0, 0, 0
    ac, bc, cc = 0, 0, 0
    for i, v in enumerate(p):
        if v == 1:
            a += L[i]
            ac += 1
        elif v == 2:
            b += L[i]
            bc += 1
        elif v == 3:
            c += L[i]
            cc += 1
    return abs(A-a) + abs(B-b) + abs(C-c) + (ac+bc+cc-3) * 10 def calc(p):
    if sum(list(set(p))) < 6:
        return INF
    a, b, c = 0, 0, 0
    ac, bc, cc = 0, 0, 0
    for i, v in enumerate(p):
        if v == 1:
            a += L[i]
            ac += 1
        elif v == 2:
            b += L[i]
            bc += 1
        elif v == 3:
            c += L[i]
            cc += 1
    return abs(A-a) + abs(B-b) + abs(C-c) + (ac+bc+cc-3) * 10 calc L = [int(input()) for i in range(N)] [int(input()) for i in range(N)] L B, C = map(int, input().split()) map(int, input().split()) B N, A, B, C = map(int, input().split()) map(int, input().split()) N ans = INF INF ans ans = min(ans, calc(p)) min(ans, calc(p)) ans INF = 10 ** 30 10 ** 30 INF
from itertools import product
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
INF = 10 ** 30
def calc(p):
    if sum(list(set(p))) < 6:
        return INF
    a, b, c = 0, 0, 0
    ac, bc, cc = 0, 0, 0
    for i, v in enumerate(p):
        if v == 1:
            a += L[i]
            ac += 1
        elif v == 2:
            b += L[i]
            bc += 1
        elif v == 3:
            c += L[i]
            cc += 1
    return abs(A-a) + abs(B-b) + abs(C-c) + (ac+bc+cc-3) * 10

ans = INF
for p in product(range(4), repeat=N):
    ans = min(ans, calc(p))
print(ans)
