def solve(i, al, bl, cl, nu):
    if i == N:
        lal, lbl, lcl = len(al), len(bl), len(cl)
        if lal == 0 or lbl == 0 or lcl == 0:
            return
        mp = 0
        mp += 10*(len(al)-1) if len(al) > 1 else 0
        mp += 10*(len(bl)-1) if len(bl) > 1 else 0
        mp += 10*(len(cl)-1) if len(cl) > 1 else 0
        mp += abs(sum(al)-A)
        mp += abs(sum(bl)-B)
        mp += abs(sum(cl)-C)
        global min_mp
        min_mp = min(min_mp, mp)
        return
    solve(i+1, al+[L[i]], bl, cl, nu)
    solve(i+1, al, bl+[L[i]], cl, nu)
    solve(i+1, al, bl, cl+[L[i]], nu)
    solve(i+1, al, bl, cl, nu+[L[i]])


N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
min_mp = 10**10
solve(0, [], [], [], [])
print(min_mp) def solve(i, al, bl, cl, nu):
    if i == N:
        lal, lbl, lcl = len(al), len(bl), len(cl)
        if lal == 0 or lbl == 0 or lcl == 0:
            return
        mp = 0
        mp += 10*(len(al)-1) if len(al) > 1 else 0
        mp += 10*(len(bl)-1) if len(bl) > 1 else 0
        mp += 10*(len(cl)-1) if len(cl) > 1 else 0
        mp += abs(sum(al)-A)
        mp += abs(sum(bl)-B)
        mp += abs(sum(cl)-C)
        global min_mp
        min_mp = min(min_mp, mp)
        return
    solve(i+1, al+[L[i]], bl, cl, nu)
    solve(i+1, al, bl+[L[i]], cl, nu)
    solve(i+1, al, bl, cl+[L[i]], nu)
    solve(i+1, al, bl, cl, nu+[L[i]]) solve if i == N:
        lal, lbl, lcl = len(al), len(bl), len(cl)
        if lal == 0 or lbl == 0 or lcl == 0:
            return
        mp = 0
        mp += 10*(len(al)-1) if len(al) > 1 else 0
        mp += 10*(len(bl)-1) if len(bl) > 1 else 0
        mp += 10*(len(cl)-1) if len(cl) > 1 else 0
        mp += abs(sum(al)-A)
        mp += abs(sum(bl)-B)
        mp += abs(sum(cl)-C)
        global min_mp
        min_mp = min(min_mp, mp)
        return
     i == N i N lal, lbl, lcl = len(al), len(bl), len(cl) lal len(al) len al lbl len(bl) len bl lcl len(cl) len cl if lal == 0 or lbl == 0 or lcl == 0:
            return
         lal == 0 or lbl == 0 or lcl == 0 lal == 0 or lbl == 0 lal == 0 lal 0 lbl == 0 lbl 0 lcl == 0 lcl 0 return mp = 0 mp 0 mp += 10*(len(al)-1) if len(al) > 1 else 0 mp 10*(len(al)-1) if len(al) > 1 else 0 len(al) > 1 len(al) len al 1 10*(len(al)-1) 10 len(al)-1 len(al) len al 1 0 mp += 10*(len(bl)-1) if len(bl) > 1 else 0 mp 10*(len(bl)-1) if len(bl) > 1 else 0 len(bl) > 1 len(bl) len bl 1 10*(len(bl)-1) 10 len(bl)-1 len(bl) len bl 1 0 mp += 10*(len(cl)-1) if len(cl) > 1 else 0 mp 10*(len(cl)-1) if len(cl) > 1 else 0 len(cl) > 1 len(cl) len cl 1 10*(len(cl)-1) 10 len(cl)-1 len(cl) len cl 1 0 mp += abs(sum(al)-A) mp abs(sum(al)-A) abs sum(al)-A sum(al) sum al A mp += abs(sum(bl)-B) mp abs(sum(bl)-B) abs sum(bl)-B sum(bl) sum bl B mp += abs(sum(cl)-C) mp abs(sum(cl)-C) abs sum(cl)-C sum(cl) sum cl C global min_mp min_mp = min(min_mp, mp) min_mp min(min_mp, mp) min min_mp mp return solve(i+1, al+[L[i]], bl, cl, nu) solve i+1 i 1 al+[L[i]] al [L[i]] L[i] L i bl cl nu solve(i+1, al, bl+[L[i]], cl, nu) solve i+1 i 1 al bl+[L[i]] bl [L[i]] L[i] L i cl nu solve(i+1, al, bl, cl+[L[i]], nu) solve i+1 i 1 al bl cl+[L[i]] cl [L[i]] L[i] L i nu solve(i+1, al, bl, cl, nu+[L[i]]) solve i+1 i 1 al bl cl nu+[L[i]] nu [L[i]] L[i] L i i i al al bl bl cl cl nu nu 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 _ 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)] min_mp = 10**10 min_mp 10**10 10 10 solve(0, [], [], [], []) solve 0 [] [] [] [] print(min_mp) print min_mp L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L C = map(int, input().split()) map(int, input().split()) C min_mp = 10**10 10**10 min_mp def solve(i, al, bl, cl, nu):
    if i == N:
        lal, lbl, lcl = len(al), len(bl), len(cl)
        if lal == 0 or lbl == 0 or lcl == 0:
            return
        mp = 0
        mp += 10*(len(al)-1) if len(al) > 1 else 0
        mp += 10*(len(bl)-1) if len(bl) > 1 else 0
        mp += 10*(len(cl)-1) if len(cl) > 1 else 0
        mp += abs(sum(al)-A)
        mp += abs(sum(bl)-B)
        mp += abs(sum(cl)-C)
        global min_mp
        min_mp = min(min_mp, mp)
        return
    solve(i+1, al+[L[i]], bl, cl, nu)
    solve(i+1, al, bl+[L[i]], cl, nu)
    solve(i+1, al, bl, cl+[L[i]], nu)
    solve(i+1, al, bl, cl, nu+[L[i]]) def solve(i, al, bl, cl, nu):
    if i == N:
        lal, lbl, lcl = len(al), len(bl), len(cl)
        if lal == 0 or lbl == 0 or lcl == 0:
            return
        mp = 0
        mp += 10*(len(al)-1) if len(al) > 1 else 0
        mp += 10*(len(bl)-1) if len(bl) > 1 else 0
        mp += 10*(len(cl)-1) if len(cl) > 1 else 0
        mp += abs(sum(al)-A)
        mp += abs(sum(bl)-B)
        mp += abs(sum(cl)-C)
        global min_mp
        min_mp = min(min_mp, mp)
        return
    solve(i+1, al+[L[i]], bl, cl, nu)
    solve(i+1, al, bl+[L[i]], cl, nu)
    solve(i+1, al, bl, cl+[L[i]], nu)
    solve(i+1, al, bl, cl, nu+[L[i]]) solve N, A, B, C = map(int, input().split()) map(int, input().split()) N B, C = map(int, input().split()) map(int, input().split()) B A, B, C = map(int, input().split()) map(int, input().split()) A
def solve(i, al, bl, cl, nu):
    if i == N:
        lal, lbl, lcl = len(al), len(bl), len(cl)
        if lal == 0 or lbl == 0 or lcl == 0:
            return
        mp = 0
        mp += 10*(len(al)-1) if len(al) > 1 else 0
        mp += 10*(len(bl)-1) if len(bl) > 1 else 0
        mp += 10*(len(cl)-1) if len(cl) > 1 else 0
        mp += abs(sum(al)-A)
        mp += abs(sum(bl)-B)
        mp += abs(sum(cl)-C)
        global min_mp
        min_mp = min(min_mp, mp)
        return
    solve(i+1, al+[L[i]], bl, cl, nu)
    solve(i+1, al, bl+[L[i]], cl, nu)
    solve(i+1, al, bl, cl+[L[i]], nu)
    solve(i+1, al, bl, cl, nu+[L[i]])


N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
min_mp = 10**10
solve(0, [], [], [], [])
print(min_mp)