MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

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

ans = INF
def dfs(i,before,score):
    global ans
    if i == N:
        if all(length > 0  for length in before):
            x,y,z = before
            for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
    else:
        dfs(i + 1,before,score)
        for j in range(3):
            before[j] += L[i]
            dfs(i + 1,before,score + 10)
            before[j] -= L[i]
dfs(0,[0,0,0],0)
print(ans) MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = 10 ** 11 INF 10 ** 11 10 11 import sys sys sys.setrecursionlimit(100000000) sys.setrecursionlimit sys setrecursionlimit 100000000 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)] ans = INF ans INF def dfs(i,before,score):
    global ans
    if i == N:
        if all(length > 0  for length in before):
            x,y,z = before
            for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
    else:
        dfs(i + 1,before,score)
        for j in range(3):
            before[j] += L[i]
            dfs(i + 1,before,score + 10)
            before[j] -= L[i] dfs global ans if i == N:
        if all(length > 0  for length in before):
            x,y,z = before
            for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
    else:
        dfs(i + 1,before,score)
        for j in range(3):
            before[j] += L[i]
            dfs(i + 1,before,score + 10)
            before[j] -= L[i] i == N i N if all(length > 0  for length in before):
            x,y,z = before
            for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
     all(length > 0  for length in before) all length > 0 length 0 x,y,z = before x before y z for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
     _ range(3) range 3 ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30) ans min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30) min ans abs(x - A) + abs(y - B) + abs(z - C) + score - 30 abs(x - A) + abs(y - B) + abs(z - C) + score abs(x - A) + abs(y - B) + abs(z - C) abs(x - A) + abs(y - B) abs(x - A) abs x - A x A abs(y - B) abs y - B y B abs(z - C) abs z - C z C score 30 x,y,z = y,z,x x y y z z x dfs(i + 1,before,score) dfs i + 1 i 1 before score for j in range(3):
            before[j] += L[i]
            dfs(i + 1,before,score + 10)
            before[j] -= L[i] j range(3) range 3 before[j] += L[i] before[j] before j L[i] L i dfs(i + 1,before,score + 10) dfs i + 1 i 1 before score + 10 score 10 before[j] -= L[i] before[j] before j L[i] L i i i before before score score dfs(0,[0,0,0],0) dfs 0 [0,0,0] 0 0 0 0 print(ans) print ans INF = 10 ** 11 10 ** 11 INF L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L ans = INF INF ans A,B,C = map(int,input().split()) map(int,input().split()) A C = map(int,input().split()) map(int,input().split()) C N,A,B,C = map(int,input().split()) map(int,input().split()) N B,C = map(int,input().split()) map(int,input().split()) B MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def dfs(i,before,score):
    global ans
    if i == N:
        if all(length > 0  for length in before):
            x,y,z = before
            for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
    else:
        dfs(i + 1,before,score)
        for j in range(3):
            before[j] += L[i]
            dfs(i + 1,before,score + 10)
            before[j] -= L[i] def dfs(i,before,score):
    global ans
    if i == N:
        if all(length > 0  for length in before):
            x,y,z = before
            for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
    else:
        dfs(i + 1,before,score)
        for j in range(3):
            before[j] += L[i]
            dfs(i + 1,before,score + 10)
            before[j] -= L[i] dfs
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

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

ans = INF
def dfs(i,before,score):
    global ans
    if i == N:
        if all(length > 0  for length in before):
            x,y,z = before
            for _ in range(3):
                ans = min(ans,abs(x - A) + abs(y - B) + abs(z - C) + score - 30)
                x,y,z = y,z,x
    else:
        dfs(i + 1,before,score)
        for j in range(3):
            before[j] += L[i]
            dfs(i + 1,before,score + 10)
            before[j] -= L[i]
dfs(0,[0,0,0],0)
print(ans)