from itertools import product
N, *P = map(int, input().split())
L = []
for _ in range(N):
    L.append(int(input()))
res = []
for p in product((0,1,2,3),repeat=N):
    tmp = [0]*4
    cnt = [0]*4
    for i in range(N):
        tmp[p[i]] += L[i]
        cnt[p[i]] += 1
    if cnt[1]>=1 and cnt[2]>=1 and cnt[3]>=1:
        res.append(sum(abs(tmp[i]-P[i-1]) + (cnt[i]-1)*10 for i in range(1,4)))
print(min(res)) from itertools import product N, *P = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split *P P L = [] L [] for _ in range(N):
    L.append(int(input())) _ range(N) range N L.append(int(input())) L.append L append int(input()) int input() input res = [] res [] for p in product((0,1,2,3),repeat=N):
    tmp = [0]*4
    cnt = [0]*4
    for i in range(N):
        tmp[p[i]] += L[i]
        cnt[p[i]] += 1
    if cnt[1]>=1 and cnt[2]>=1 and cnt[3]>=1:
        res.append(sum(abs(tmp[i]-P[i-1]) + (cnt[i]-1)*10 for i in range(1,4))) p product((0,1,2,3),repeat=N) product (0,1,2,3) 0 1 2 3 repeat=N repeat N tmp = [0]*4 tmp [0]*4 [0] 0 4 cnt = [0]*4 cnt [0]*4 [0] 0 4 for i in range(N):
        tmp[p[i]] += L[i]
        cnt[p[i]] += 1
     i range(N) range N tmp[p[i]] += L[i] tmp[p[i]] tmp p[i] p i L[i] L i cnt[p[i]] += 1 cnt[p[i]] cnt p[i] p i 1 if cnt[1]>=1 and cnt[2]>=1 and cnt[3]>=1:
        res.append(sum(abs(tmp[i]-P[i-1]) + (cnt[i]-1)*10 for i in range(1,4))) cnt[1]>=1 and cnt[2]>=1 and cnt[3]>=1 cnt[1]>=1 and cnt[2]>=1 cnt[1]>=1 cnt[1] cnt 1 1 cnt[2]>=1 cnt[2] cnt 2 1 cnt[3]>=1 cnt[3] cnt 3 1 res.append(sum(abs(tmp[i]-P[i-1]) + (cnt[i]-1)*10 for i in range(1,4))) res.append res append sum(abs(tmp[i]-P[i-1]) + (cnt[i]-1)*10 for i in range(1,4)) sum abs(tmp[i]-P[i-1]) + (cnt[i]-1)*10 abs(tmp[i]-P[i-1]) abs tmp[i]-P[i-1] tmp[i] tmp i P[i-1] P i-1 i 1 (cnt[i]-1)*10 cnt[i]-1 cnt[i] cnt i 1 10 print(min(res)) print min(res) min res L = [] [] L res = [] [] res cnt = [0]*4 [0]*4 cnt tmp = [0]*4 [0]*4 tmp N, *P = map(int, input().split()) map(int, input().split()) N
from itertools import product
N, *P = map(int, input().split())
L = []
for _ in range(N):
    L.append(int(input()))
res = []
for p in product((0,1,2,3),repeat=N):
    tmp = [0]*4
    cnt = [0]*4
    for i in range(N):
        tmp[p[i]] += L[i]
        cnt[p[i]] += 1
    if cnt[1]>=1 and cnt[2]>=1 and cnt[3]>=1:
        res.append(sum(abs(tmp[i]-P[i-1]) + (cnt[i]-1)*10 for i in range(1,4)))
print(min(res))