def dfs(ka, kb, kc, cnta, cntb, cntc, phase):
    global ans
    if phase == n:
        if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))
        return
    dfs(ka+l[phase], kb, kc, cnta+1, cntb, cntc, phase+1)
    dfs(ka, kb+l[phase], kc, cnta, cntb+1, cntc, phase+1)
    dfs(ka, kb, kc+l[phase], cnta, cntb, cntc+1, phase+1)
    dfs(ka, kb, kc, cnta, cntb, cntc, phase+1)


n,a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 10**9
dfs(0,0,0,0,0,0,0)
print(ans) def dfs(ka, kb, kc, cnta, cntb, cntc, phase):
    global ans
    if phase == n:
        if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))
        return
    dfs(ka+l[phase], kb, kc, cnta+1, cntb, cntc, phase+1)
    dfs(ka, kb+l[phase], kc, cnta, cntb+1, cntc, phase+1)
    dfs(ka, kb, kc+l[phase], cnta, cntb, cntc+1, phase+1)
    dfs(ka, kb, kc, cnta, cntb, cntc, phase+1) dfs global ans if phase == n:
        if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))
        return
     phase == n phase n if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))
         0 < cnta and 0 < cntb and 0 < cntc 0 < cnta and 0 < cntb 0 < cnta 0 cnta 0 < cntb 0 cntb 0 < cntc 0 cntc ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3)) ans min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3)) min ans abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3) abs(a-ka) + abs(b-kb) + abs(c-kc) abs(a-ka) + abs(b-kb) abs(a-ka) abs a-ka a ka abs(b-kb) abs b-kb b kb abs(c-kc) abs c-kc c kc 10*(cnta+cntb+cntc-3) 10 cnta+cntb+cntc-3 cnta+cntb+cntc cnta+cntb cnta cntb cntc 3 return dfs(ka+l[phase], kb, kc, cnta+1, cntb, cntc, phase+1) dfs ka+l[phase] ka l[phase] l phase kb kc cnta+1 cnta 1 cntb cntc phase+1 phase 1 dfs(ka, kb+l[phase], kc, cnta, cntb+1, cntc, phase+1) dfs ka kb+l[phase] kb l[phase] l phase kc cnta cntb+1 cntb 1 cntc phase+1 phase 1 dfs(ka, kb, kc+l[phase], cnta, cntb, cntc+1, phase+1) dfs ka kb kc+l[phase] kc l[phase] l phase cnta cntb cntc+1 cntc 1 phase+1 phase 1 dfs(ka, kb, kc, cnta, cntb, cntc, phase+1) dfs ka kb kc cnta cntb cntc phase+1 phase 1 ka ka kb kb kc kc cnta cnta cntb cntb cntc cntc phase phase 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 = 10**9 ans 10**9 10 9 dfs(0,0,0,0,0,0,0) dfs 0 0 0 0 0 0 0 print(ans) print ans c = map(int, input().split()) map(int, input().split()) c def dfs(ka, kb, kc, cnta, cntb, cntc, phase):
    global ans
    if phase == n:
        if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))
        return
    dfs(ka+l[phase], kb, kc, cnta+1, cntb, cntc, phase+1)
    dfs(ka, kb+l[phase], kc, cnta, cntb+1, cntc, phase+1)
    dfs(ka, kb, kc+l[phase], cnta, cntb, cntc+1, phase+1)
    dfs(ka, kb, kc, cnta, cntb, cntc, phase+1) def dfs(ka, kb, kc, cnta, cntb, cntc, phase):
    global ans
    if phase == n:
        if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))
        return
    dfs(ka+l[phase], kb, kc, cnta+1, cntb, cntc, phase+1)
    dfs(ka, kb+l[phase], kc, cnta, cntb+1, cntc, phase+1)
    dfs(ka, kb, kc+l[phase], cnta, cntb, cntc+1, phase+1)
    dfs(ka, kb, kc, cnta, cntb, cntc, phase+1) dfs b,c = map(int, input().split()) map(int, input().split()) b ans = 10**9 10**9 ans l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l a,b,c = map(int, input().split()) map(int, input().split()) a n,a,b,c = map(int, input().split()) map(int, input().split()) n
def dfs(ka, kb, kc, cnta, cntb, cntc, phase):
    global ans
    if phase == n:
        if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))
        return
    dfs(ka+l[phase], kb, kc, cnta+1, cntb, cntc, phase+1)
    dfs(ka, kb+l[phase], kc, cnta, cntb+1, cntc, phase+1)
    dfs(ka, kb, kc+l[phase], cnta, cntb, cntc+1, phase+1)
    dfs(ka, kb, kc, cnta, cntb, cntc, phase+1)


n,a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 10**9
dfs(0,0,0,0,0,0,0)
print(ans)