import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B, C = mapint()
Ls = [int(input()) for _ in range(N)]
ans = 10**18
def dfs(a, b, c, idx, magic):
    global ans
    if idx==N:
        if a==0 or b==0 or c==0:
            return
        magic -= 30
        magic += abs(A-a)
        magic += abs(B-b)
        magic += abs(C-c)
        ans = min(ans, magic)
        return
    nx = Ls[idx]
    dfs(a+nx, b, c, idx+1, magic+10)
    dfs(a, b+nx, c, idx+1, magic+10)
    dfs(a, b, c+nx, idx+1, magic+10)
    dfs(a, b, c, idx+1, magic)

dfs(0, 0, 0, 0, 0)
print(ans) import sys sys def input(): return sys.stdin.readline().strip() input def mapint(): return map(int, input().split()) mapint sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 N, A, B, C = mapint() N mapint() mapint 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 Ls = [int(input()) for _ in range(N)] Ls [int(input()) for _ in range(N)] ans = 10**18 ans 10**18 10 18 def dfs(a, b, c, idx, magic):
    global ans
    if idx==N:
        if a==0 or b==0 or c==0:
            return
        magic -= 30
        magic += abs(A-a)
        magic += abs(B-b)
        magic += abs(C-c)
        ans = min(ans, magic)
        return
    nx = Ls[idx]
    dfs(a+nx, b, c, idx+1, magic+10)
    dfs(a, b+nx, c, idx+1, magic+10)
    dfs(a, b, c+nx, idx+1, magic+10)
    dfs(a, b, c, idx+1, magic) dfs global ans if idx==N:
        if a==0 or b==0 or c==0:
            return
        magic -= 30
        magic += abs(A-a)
        magic += abs(B-b)
        magic += abs(C-c)
        ans = min(ans, magic)
        return
     idx==N idx N if a==0 or b==0 or c==0:
            return
         a==0 or b==0 or c==0 a==0 or b==0 a==0 a 0 b==0 b 0 c==0 c 0 return magic -= 30 magic 30 magic += abs(A-a) magic abs(A-a) abs A-a A a magic += abs(B-b) magic abs(B-b) abs B-b B b magic += abs(C-c) magic abs(C-c) abs C-c C c ans = min(ans, magic) ans min(ans, magic) min ans magic return nx = Ls[idx] nx Ls[idx] Ls idx dfs(a+nx, b, c, idx+1, magic+10) dfs a+nx a nx b c idx+1 idx 1 magic+10 magic 10 dfs(a, b+nx, c, idx+1, magic+10) dfs a b+nx b nx c idx+1 idx 1 magic+10 magic 10 dfs(a, b, c+nx, idx+1, magic+10) dfs a b c+nx c nx idx+1 idx 1 magic+10 magic 10 dfs(a, b, c, idx+1, magic) dfs a b c idx+1 idx 1 magic a a b b c c idx idx magic magic dfs(0, 0, 0, 0, 0) dfs 0 0 0 0 0 print(ans) print ans def mapint(): return map(int, input().split()) def mapint(): return map(int, input().split()) mapint B, C = mapint() mapint() B ans = 10**18 10**18 ans def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input A, B, C = mapint() mapint() A N, A, B, C = mapint() mapint() N Ls = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] Ls def dfs(a, b, c, idx, magic):
    global ans
    if idx==N:
        if a==0 or b==0 or c==0:
            return
        magic -= 30
        magic += abs(A-a)
        magic += abs(B-b)
        magic += abs(C-c)
        ans = min(ans, magic)
        return
    nx = Ls[idx]
    dfs(a+nx, b, c, idx+1, magic+10)
    dfs(a, b+nx, c, idx+1, magic+10)
    dfs(a, b, c+nx, idx+1, magic+10)
    dfs(a, b, c, idx+1, magic) def dfs(a, b, c, idx, magic):
    global ans
    if idx==N:
        if a==0 or b==0 or c==0:
            return
        magic -= 30
        magic += abs(A-a)
        magic += abs(B-b)
        magic += abs(C-c)
        ans = min(ans, magic)
        return
    nx = Ls[idx]
    dfs(a+nx, b, c, idx+1, magic+10)
    dfs(a, b+nx, c, idx+1, magic+10)
    dfs(a, b, c+nx, idx+1, magic+10)
    dfs(a, b, c, idx+1, magic) dfs C = mapint() mapint() C
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B, C = mapint()
Ls = [int(input()) for _ in range(N)]
ans = 10**18
def dfs(a, b, c, idx, magic):
    global ans
    if idx==N:
        if a==0 or b==0 or c==0:
            return
        magic -= 30
        magic += abs(A-a)
        magic += abs(B-b)
        magic += abs(C-c)
        ans = min(ans, magic)
        return
    nx = Ls[idx]
    dfs(a+nx, b, c, idx+1, magic+10)
    dfs(a, b+nx, c, idx+1, magic+10)
    dfs(a, b, c+nx, idx+1, magic+10)
    dfs(a, b, c, idx+1, magic)

dfs(0, 0, 0, 0, 0)
print(ans)
