N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    a,b,c = [],[],[]
    cost = 0
    for j in range(N):
        r = (i//(4**j)) % 4
        if r == 1:
            a.append(l[j])
        elif r == 2:
            b.append(l[j])
        elif r == 3:
            c.append(l[j])
    if a and b and c:
        cost += sum(max((len(x)-1), 0)*10 for x in [a,b,c])
        a = sum(a)
        b = sum(b)
        c = sum(c)
        cost += sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)])
        ans = min(ans, cost)
print(ans) 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 = float("inf") ans float("inf") float "inf" for i in range(4**N):
    a,b,c = [],[],[]
    cost = 0
    for j in range(N):
        r = (i//(4**j)) % 4
        if r == 1:
            a.append(l[j])
        elif r == 2:
            b.append(l[j])
        elif r == 3:
            c.append(l[j])
    if a and b and c:
        cost += sum(max((len(x)-1), 0)*10 for x in [a,b,c])
        a = sum(a)
        b = sum(b)
        c = sum(c)
        cost += sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)])
        ans = min(ans, cost) i range(4**N) range 4**N 4 N a,b,c = [],[],[] a [] b [] c [] cost = 0 cost 0 for j in range(N):
        r = (i//(4**j)) % 4
        if r == 1:
            a.append(l[j])
        elif r == 2:
            b.append(l[j])
        elif r == 3:
            c.append(l[j])
     j range(N) range N r = (i//(4**j)) % 4 r (i//(4**j)) % 4 i//(4**j) i 4**j 4 j 4 if r == 1:
            a.append(l[j])
        elif r == 2:
            b.append(l[j])
        elif r == 3:
            c.append(l[j])
     r == 1 r 1 a.append(l[j]) a.append a append l[j] l j elif r == 2:
            b.append(l[j])
         r == 2 r 2 b.append(l[j]) b.append b append l[j] l j elif r == 3:
            c.append(l[j])
     r == 3 r 3 c.append(l[j]) c.append c append l[j] l j if a and b and c:
        cost += sum(max((len(x)-1), 0)*10 for x in [a,b,c])
        a = sum(a)
        b = sum(b)
        c = sum(c)
        cost += sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)])
        ans = min(ans, cost) a and b and c a and b a b c cost += sum(max((len(x)-1), 0)*10 for x in [a,b,c]) cost sum(max((len(x)-1), 0)*10 for x in [a,b,c]) sum max((len(x)-1), 0)*10 max((len(x)-1), 0) max len(x)-1 len(x) len x 1 0 10 a = sum(a) a sum(a) sum a b = sum(b) b sum(b) sum b c = sum(c) c sum(c) sum c cost += sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)]) cost sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)]) sum abs(x-y) abs x-y x y ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans B,C = map(int,input().split()) map(int,input().split()) B b = sum(b) sum(b) b a,b,c = [],[],[] [] a c = sum(c) sum(c) c 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 r = (i//(4**j)) % 4 (i//(4**j)) % 4 r cost += sum(max((len(x)-1), 0)*10 for x in [a,b,c]) sum(max((len(x)-1), 0)*10 for x in [a,b,c]) cost C = map(int,input().split()) map(int,input().split()) C cost = 0 0 cost ans = min(ans, cost) min(ans, cost) ans c = [],[],[] [] c cost += sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)]) sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)]) cost ans = float("inf") float("inf") ans b,c = [],[],[] [] b N,A,B,C = map(int,input().split()) map(int,input().split()) N a = sum(a) sum(a) a
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    a,b,c = [],[],[]
    cost = 0
    for j in range(N):
        r = (i//(4**j)) % 4
        if r == 1:
            a.append(l[j])
        elif r == 2:
            b.append(l[j])
        elif r == 3:
            c.append(l[j])
    if a and b and c:
        cost += sum(max((len(x)-1), 0)*10 for x in [a,b,c])
        a = sum(a)
        b = sum(b)
        c = sum(c)
        cost += sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)])
        ans = min(ans, cost)
print(ans)