n, A, B, C = (int(i) for i in input().split())
l = [int(input()) for i in range(n)]
a = []
b = []
c = []

def furiwake(x):
    global a
    global b
    global c
    a = []
    b = []
    c = []
    for i in range(1, n+1):
        if dig4(x, i) == 0:
            a.append(l[i-1])
        if dig4(x, i) == 1:
            b.append(l[i-1])
        if dig4(x, i) == 2:
            c.append(l[i-1])

def dig4(n, k):
    return (n%(4**k))//(4**(k-1))

def cost():
    costa = 10 * (len(a)-1) + abs(sum(a)-A)
    costb = 10 * (len(b)-1) + abs(sum(b)-B)
    costc = 10 * (len(c)-1) + abs(sum(c)-C)
    return costa+costb+costc

ans = 1000000000
for i in range(1, 4**8):
    furiwake(i)
    if(len(a)*len(b)*len(c)):
        ans = min(ans, cost())
print(ans) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n, A, B, C = (int(i) for i in input().split()) n (int(i) for i in input().split()) A B C int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] a = [] a [] b = [] b [] c = [] c [] def furiwake(x):
    global a
    global b
    global c
    a = []
    b = []
    c = []
    for i in range(1, n+1):
        if dig4(x, i) == 0:
            a.append(l[i-1])
        if dig4(x, i) == 1:
            b.append(l[i-1])
        if dig4(x, i) == 2:
            c.append(l[i-1]) furiwake global a global b global c a = [] a [] b = [] b [] c = [] c [] for i in range(1, n+1):
        if dig4(x, i) == 0:
            a.append(l[i-1])
        if dig4(x, i) == 1:
            b.append(l[i-1])
        if dig4(x, i) == 2:
            c.append(l[i-1]) i range(1, n+1) range 1 n+1 n 1 if dig4(x, i) == 0:
            a.append(l[i-1])
         dig4(x, i) == 0 dig4(x, i) dig4 x i 0 a.append(l[i-1]) a.append a append l[i-1] l i-1 i 1 if dig4(x, i) == 1:
            b.append(l[i-1])
         dig4(x, i) == 1 dig4(x, i) dig4 x i 1 b.append(l[i-1]) b.append b append l[i-1] l i-1 i 1 if dig4(x, i) == 2:
            c.append(l[i-1]) dig4(x, i) == 2 dig4(x, i) dig4 x i 2 c.append(l[i-1]) c.append c append l[i-1] l i-1 i 1 x x def dig4(n, k):
    return (n%(4**k))//(4**(k-1)) dig4 return (n%(4**k))//(4**(k-1)) (n%(4**k))//(4**(k-1)) n%(4**k) n 4**k 4 k 4**(k-1) 4 k-1 k 1 n n k k def cost():
    costa = 10 * (len(a)-1) + abs(sum(a)-A)
    costb = 10 * (len(b)-1) + abs(sum(b)-B)
    costc = 10 * (len(c)-1) + abs(sum(c)-C)
    return costa+costb+costc cost costa = 10 * (len(a)-1) + abs(sum(a)-A) costa 10 * (len(a)-1) + abs(sum(a)-A) 10 * (len(a)-1) 10 len(a)-1 len(a) len a 1 abs(sum(a)-A) abs sum(a)-A sum(a) sum a A costb = 10 * (len(b)-1) + abs(sum(b)-B) costb 10 * (len(b)-1) + abs(sum(b)-B) 10 * (len(b)-1) 10 len(b)-1 len(b) len b 1 abs(sum(b)-B) abs sum(b)-B sum(b) sum b B costc = 10 * (len(c)-1) + abs(sum(c)-C) costc 10 * (len(c)-1) + abs(sum(c)-C) 10 * (len(c)-1) 10 len(c)-1 len(c) len c 1 abs(sum(c)-C) abs sum(c)-C sum(c) sum c C return costa+costb+costc costa+costb+costc costa+costb costa costb costc ans = 1000000000 ans 1000000000 for i in range(1, 4**8):
    furiwake(i)
    if(len(a)*len(b)*len(c)):
        ans = min(ans, cost()) i range(1, 4**8) range 1 4**8 4 8 furiwake(i) furiwake i if(len(a)*len(b)*len(c)):
        ans = min(ans, cost()) len(a)*len(b)*len(c) len(a)*len(b) len(a) len a len(b) len b len(c) len c ans = min(ans, cost()) ans min(ans, cost()) min ans cost() cost print(ans) print ans B, C = (int(i) for i in input().split()) (int(i) for i in input().split()) B c = [] [] c def dig4(n, k):
    return (n%(4**k))//(4**(k-1)) def dig4(n, k):
    return (n%(4**k))//(4**(k-1)) dig4 def furiwake(x):
    global a
    global b
    global c
    a = []
    b = []
    c = []
    for i in range(1, n+1):
        if dig4(x, i) == 0:
            a.append(l[i-1])
        if dig4(x, i) == 1:
            b.append(l[i-1])
        if dig4(x, i) == 2:
            c.append(l[i-1]) def furiwake(x):
    global a
    global b
    global c
    a = []
    b = []
    c = []
    for i in range(1, n+1):
        if dig4(x, i) == 0:
            a.append(l[i-1])
        if dig4(x, i) == 1:
            b.append(l[i-1])
        if dig4(x, i) == 2:
            c.append(l[i-1]) furiwake def cost():
    costa = 10 * (len(a)-1) + abs(sum(a)-A)
    costb = 10 * (len(b)-1) + abs(sum(b)-B)
    costc = 10 * (len(c)-1) + abs(sum(c)-C)
    return costa+costb+costc def cost():
    costa = 10 * (len(a)-1) + abs(sum(a)-A)
    costb = 10 * (len(b)-1) + abs(sum(b)-B)
    costc = 10 * (len(c)-1) + abs(sum(c)-C)
    return costa+costb+costc cost n, A, B, C = (int(i) for i in input().split()) (int(i) for i in input().split()) n a = [] [] a l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l ans = min(ans, cost()) min(ans, cost()) ans C = (int(i) for i in input().split()) (int(i) for i in input().split()) C ans = 1000000000 1000000000 ans A, B, C = (int(i) for i in input().split()) (int(i) for i in input().split()) A b = [] [] b
n, A, B, C = (int(i) for i in input().split())
l = [int(input()) for i in range(n)]
a = []
b = []
c = []

def furiwake(x):
    global a
    global b
    global c
    a = []
    b = []
    c = []
    for i in range(1, n+1):
        if dig4(x, i) == 0:
            a.append(l[i-1])
        if dig4(x, i) == 1:
            b.append(l[i-1])
        if dig4(x, i) == 2:
            c.append(l[i-1])

def dig4(n, k):
    return (n%(4**k))//(4**(k-1))

def cost():
    costa = 10 * (len(a)-1) + abs(sum(a)-A)
    costb = 10 * (len(b)-1) + abs(sum(b)-B)
    costc = 10 * (len(c)-1) + abs(sum(c)-C)
    return costa+costb+costc

ans = 1000000000
for i in range(1, 4**8):
    furiwake(i)
    if(len(a)*len(b)*len(c)):
        ans = min(ans, cost())
print(ans)