[N,A,B,C] = list(map(int,input().split()))
L = []
for i in range(N):
    L.append(int(input()))

import itertools
cases = list(itertools.product([0,1,2,3], repeat=N))

out = float("inf")

for case in cases:
    As =[]
    Bs =[]
    Cs =[]
    for i in range(N):
        if case[i]==1:
            As.append(i)
        if case[i]==2:
            Bs.append(i)
        if case[i]==3:
            Cs.append(i)
    LA, LB, LC = len(As),len(Bs),len(Cs)
    if LA*LB*LC==0:
        continue
    point = (LA-1)*10 + (LB-1)*10 + (LC-1)*10

    Ah = 0
    for take in As:
        Ah+=L[take]
    Bh = 0
    for take in Bs:
        Bh+=L[take]
    Ch = 0
    for take in Cs:
        Ch+=L[take]
    point += abs(A-Ah) + abs(B-Bh) + abs(C-Ch)

    if point < out:
        out = point

print(out) [N,A,B,C] = list(map(int,input().split())) [N,A,B,C] N A B C list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split L = [] L [] for i in range(N):
    L.append(int(input())) i range(N) range N L.append(int(input())) L.append L append int(input()) int input() input import itertools itertools cases = list(itertools.product([0,1,2,3], repeat=N)) cases list(itertools.product([0,1,2,3], repeat=N)) list itertools.product([0,1,2,3], repeat=N) itertools.product itertools product [0,1,2,3] 0 1 2 3 repeat=N repeat N out = float("inf") out float("inf") float "inf" for case in cases:
    As =[]
    Bs =[]
    Cs =[]
    for i in range(N):
        if case[i]==1:
            As.append(i)
        if case[i]==2:
            Bs.append(i)
        if case[i]==3:
            Cs.append(i)
    LA, LB, LC = len(As),len(Bs),len(Cs)
    if LA*LB*LC==0:
        continue
    point = (LA-1)*10 + (LB-1)*10 + (LC-1)*10

    Ah = 0
    for take in As:
        Ah+=L[take]
    Bh = 0
    for take in Bs:
        Bh+=L[take]
    Ch = 0
    for take in Cs:
        Ch+=L[take]
    point += abs(A-Ah) + abs(B-Bh) + abs(C-Ch)

    if point < out:
        out = point case cases As =[] As [] Bs =[] Bs [] Cs =[] Cs [] for i in range(N):
        if case[i]==1:
            As.append(i)
        if case[i]==2:
            Bs.append(i)
        if case[i]==3:
            Cs.append(i)
     i range(N) range N if case[i]==1:
            As.append(i)
         case[i]==1 case[i] case i 1 As.append(i) As.append As append i if case[i]==2:
            Bs.append(i)
         case[i]==2 case[i] case i 2 Bs.append(i) Bs.append Bs append i if case[i]==3:
            Cs.append(i)
     case[i]==3 case[i] case i 3 Cs.append(i) Cs.append Cs append i LA, LB, LC = len(As),len(Bs),len(Cs) LA len(As) len As LB len(Bs) len Bs LC len(Cs) len Cs if LA*LB*LC==0:
        continue
     LA*LB*LC==0 LA*LB*LC LA*LB LA LB LC 0 continue point = (LA-1)*10 + (LB-1)*10 + (LC-1)*10 point (LA-1)*10 + (LB-1)*10 + (LC-1)*10 (LA-1)*10 + (LB-1)*10 (LA-1)*10 LA-1 LA 1 10 (LB-1)*10 LB-1 LB 1 10 (LC-1)*10 LC-1 LC 1 10 Ah = 0 Ah 0 for take in As:
        Ah+=L[take]
     take As Ah+=L[take] Ah L[take] L take Bh = 0 Bh 0 for take in Bs:
        Bh+=L[take]
     take Bs Bh+=L[take] Bh L[take] L take Ch = 0 Ch 0 for take in Cs:
        Ch+=L[take]
     take Cs Ch+=L[take] Ch L[take] L take point += abs(A-Ah) + abs(B-Bh) + abs(C-Ch) point abs(A-Ah) + abs(B-Bh) + abs(C-Ch) abs(A-Ah) + abs(B-Bh) abs(A-Ah) abs A-Ah A Ah abs(B-Bh) abs B-Bh B Bh abs(C-Ch) abs C-Ch C Ch if point < out:
        out = point point < out point out out = point out point print(out) print out Ch+=L[take] L[take] Ch out = point point out LA, LB, LC = len(As),len(Bs),len(Cs) len(As) LA Bh = 0 0 Bh Ah = 0 0 Ah LB, LC = len(As),len(Bs),len(Cs) len(Bs) LB cases = list(itertools.product([0,1,2,3], repeat=N)) list(itertools.product([0,1,2,3], repeat=N)) cases Bh+=L[take] L[take] Bh L = [] [] L out = float("inf") float("inf") out Ah+=L[take] L[take] Ah Ch = 0 0 Ch point += abs(A-Ah) + abs(B-Bh) + abs(C-Ch) abs(A-Ah) + abs(B-Bh) + abs(C-Ch) point As =[] [] As Cs =[] [] Cs LC = len(As),len(Bs),len(Cs) len(Cs) LC Bs =[] [] Bs point = (LA-1)*10 + (LB-1)*10 + (LC-1)*10 (LA-1)*10 + (LB-1)*10 + (LC-1)*10 point
[N,A,B,C] = list(map(int,input().split()))
L = []
for i in range(N):
    L.append(int(input()))

import itertools
cases = list(itertools.product([0,1,2,3], repeat=N))

out = float("inf")

for case in cases:
    As =[]
    Bs =[]
    Cs =[]
    for i in range(N):
        if case[i]==1:
            As.append(i)
        if case[i]==2:
            Bs.append(i)
        if case[i]==3:
            Cs.append(i)
    LA, LB, LC = len(As),len(Bs),len(Cs)
    if LA*LB*LC==0:
        continue
    point = (LA-1)*10 + (LB-1)*10 + (LC-1)*10

    Ah = 0
    for take in As:
        Ah+=L[take]
    Bh = 0
    for take in Bs:
        Bh+=L[take]
    Ch = 0
    for take in Cs:
        Ch+=L[take]
    point += abs(A-Ah) + abs(B-Bh) + abs(C-Ch)

    if point < out:
        out = point

print(out)
