import itertools

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

INF = 10**18
ans = INF

for ptn in itertools.product([0,1,2,3], repeat=N):
    x = [0] * 4
    MP = 0
    for take, length in zip(ptn, L):
        if take == 3:  # 使わない
            continue
        if x[take] != 0:
            MP += 10
        x[take] += length
    if x[0]==0 or x[1]==0 or x[2]==0:
        continue
    MP += abs(A-x[0])
    MP += abs(B-x[1])
    MP += abs(C-x[2])
    if ans > MP:
        ans = MP
print(ans) import itertools itertools 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)] INF = 10**18 INF 10**18 10 18 ans = INF ans INF for ptn in itertools.product([0,1,2,3], repeat=N):
    x = [0] * 4
    MP = 0
    for take, length in zip(ptn, L):
        if take == 3:  # 使わない
            continue
        if x[take] != 0:
            MP += 10
        x[take] += length
    if x[0]==0 or x[1]==0 or x[2]==0:
        continue
    MP += abs(A-x[0])
    MP += abs(B-x[1])
    MP += abs(C-x[2])
    if ans > MP:
        ans = MP ptn itertools.product([0,1,2,3], repeat=N) itertools.product itertools product [0,1,2,3] 0 1 2 3 repeat=N repeat N x = [0] * 4 x [0] * 4 [0] 0 4 MP = 0 MP 0 for take, length in zip(ptn, L):
        if take == 3:  # 使わない
            continue
        if x[take] != 0:
            MP += 10
        x[take] += length
     take length zip(ptn, L) zip ptn L if take == 3:  # 使わない
            continue
         take == 3 take 3 continue if x[take] != 0:
            MP += 10
         x[take] != 0 x[take] x take 0 MP += 10 MP 10 x[take] += length x[take] x take length if x[0]==0 or x[1]==0 or x[2]==0:
        continue
     x[0]==0 or x[1]==0 or x[2]==0 x[0]==0 or x[1]==0 x[0]==0 x[0] x 0 0 x[1]==0 x[1] x 1 0 x[2]==0 x[2] x 2 0 continue MP += abs(A-x[0]) MP abs(A-x[0]) abs A-x[0] A x[0] x 0 MP += abs(B-x[1]) MP abs(B-x[1]) abs B-x[1] B x[1] x 1 MP += abs(C-x[2]) MP abs(C-x[2]) abs C-x[2] C x[2] x 2 if ans > MP:
        ans = MP ans > MP ans MP ans = MP ans MP print(ans) print ans N,A,B,C = map(int,input().split()) map(int,input().split()) N A,B,C = map(int,input().split()) map(int,input().split()) A INF = 10**18 10**18 INF ans = INF INF ans MP += 10 10 MP MP = 0 0 MP B,C = map(int,input().split()) map(int,input().split()) B MP += abs(B-x[1]) abs(B-x[1]) MP ans = MP MP ans x = [0] * 4 [0] * 4 x MP += abs(C-x[2]) abs(C-x[2]) 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 MP += abs(A-x[0]) abs(A-x[0]) MP
import itertools

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

INF = 10**18
ans = INF

for ptn in itertools.product([0,1,2,3], repeat=N):
    x = [0] * 4
    MP = 0
    for take, length in zip(ptn, L):
        if take == 3:  # 使わない
            continue
        if x[take] != 0:
            MP += 10
        x[take] += length
    if x[0]==0 or x[1]==0 or x[2]==0:
        continue
    MP += abs(A-x[0])
    MP += abs(B-x[1])
    MP += abs(C-x[2])
    if ans > MP:
        ans = MP
print(ans)