import sys

N,A,B,C = map(int,sys.stdin.readline().rstrip().split())
l = [int(sys.stdin.readline().rstrip()) for _ in range(N)]

from itertools import product

# 各々の竹をAに使うか、Bに使うか、Cに使うか、使わないかで全探索

ans = 10**18
for a in list(product([1,2,3,4],repeat=N)):
    X,Y,Z = [],[],[]
    for i in range(N):
        if a[i] == 1:
            X.append(l[i])
        elif a[i] == 2:
            Y.append(l[i])
        elif a[i] == 3:
            Z.append(l[i])
    if len(X) == 0 or len(Y) == 0 or len(Z) == 0:
        continue
    else:
        a = 0
        a += 10*(len(X)+len(Y)+len(Z)-3)
        a += abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z))
        if a < ans:
            ans = a

print(ans) import sys sys N,A,B,C = map(int,sys.stdin.readline().rstrip().split()) N map(int,sys.stdin.readline().rstrip().split()) map int sys.stdin.readline().rstrip().split() sys.stdin.readline().rstrip().split sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip split A B C int(sys.stdin.readline().rstrip()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(sys.stdin.readline().rstrip()) int sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip l = [int(sys.stdin.readline().rstrip()) for _ in range(N)] l [int(sys.stdin.readline().rstrip()) for _ in range(N)] from itertools import product ans = 10**18 ans 10**18 10 18 for a in list(product([1,2,3,4],repeat=N)):
    X,Y,Z = [],[],[]
    for i in range(N):
        if a[i] == 1:
            X.append(l[i])
        elif a[i] == 2:
            Y.append(l[i])
        elif a[i] == 3:
            Z.append(l[i])
    if len(X) == 0 or len(Y) == 0 or len(Z) == 0:
        continue
    else:
        a = 0
        a += 10*(len(X)+len(Y)+len(Z)-3)
        a += abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z))
        if a < ans:
            ans = a a list(product([1,2,3,4],repeat=N)) list product([1,2,3,4],repeat=N) product [1,2,3,4] 1 2 3 4 repeat=N repeat N X,Y,Z = [],[],[] X [] Y [] Z [] for i in range(N):
        if a[i] == 1:
            X.append(l[i])
        elif a[i] == 2:
            Y.append(l[i])
        elif a[i] == 3:
            Z.append(l[i])
     i range(N) range N if a[i] == 1:
            X.append(l[i])
        elif a[i] == 2:
            Y.append(l[i])
        elif a[i] == 3:
            Z.append(l[i])
     a[i] == 1 a[i] a i 1 X.append(l[i]) X.append X append l[i] l i elif a[i] == 2:
            Y.append(l[i])
         a[i] == 2 a[i] a i 2 Y.append(l[i]) Y.append Y append l[i] l i elif a[i] == 3:
            Z.append(l[i])
     a[i] == 3 a[i] a i 3 Z.append(l[i]) Z.append Z append l[i] l i if len(X) == 0 or len(Y) == 0 or len(Z) == 0:
        continue
    else:
        a = 0
        a += 10*(len(X)+len(Y)+len(Z)-3)
        a += abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z))
        if a < ans:
            ans = a len(X) == 0 or len(Y) == 0 or len(Z) == 0 len(X) == 0 or len(Y) == 0 len(X) == 0 len(X) len X 0 len(Y) == 0 len(Y) len Y 0 len(Z) == 0 len(Z) len Z 0 continue a = 0 a 0 a += 10*(len(X)+len(Y)+len(Z)-3) a 10*(len(X)+len(Y)+len(Z)-3) 10 len(X)+len(Y)+len(Z)-3 len(X)+len(Y)+len(Z) len(X)+len(Y) len(X) len X len(Y) len Y len(Z) len Z 3 a += abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z)) a abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z)) abs(A-sum(X)) + abs(B-sum(Y)) abs(A-sum(X)) abs A-sum(X) A sum(X) sum X abs(B-sum(Y)) abs B-sum(Y) B sum(Y) sum Y abs(C-sum(Z)) abs C-sum(Z) C sum(Z) sum Z if a < ans:
            ans = a a < ans a ans ans = a ans a print(ans) print ans ans = a a ans A,B,C = map(int,sys.stdin.readline().rstrip().split()) map(int,sys.stdin.readline().rstrip().split()) A a += 10*(len(X)+len(Y)+len(Z)-3) 10*(len(X)+len(Y)+len(Z)-3) a Z = [],[],[] [] Z C = map(int,sys.stdin.readline().rstrip().split()) map(int,sys.stdin.readline().rstrip().split()) C ans = 10**18 10**18 ans B,C = map(int,sys.stdin.readline().rstrip().split()) map(int,sys.stdin.readline().rstrip().split()) B a = 0 0 a N,A,B,C = map(int,sys.stdin.readline().rstrip().split()) map(int,sys.stdin.readline().rstrip().split()) N X,Y,Z = [],[],[] [] X Y,Z = [],[],[] [] Y l = [int(sys.stdin.readline().rstrip()) for _ in range(N)] [int(sys.stdin.readline().rstrip()) for _ in range(N)] l a += abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z)) abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z)) a
import sys

N,A,B,C = map(int,sys.stdin.readline().rstrip().split())
l = [int(sys.stdin.readline().rstrip()) for _ in range(N)]

from itertools import product

# 各々の竹をAに使うか、Bに使うか、Cに使うか、使わないかで全探索

ans = 10**18
for a in list(product([1,2,3,4],repeat=N)):
    X,Y,Z = [],[],[]
    for i in range(N):
        if a[i] == 1:
            X.append(l[i])
        elif a[i] == 2:
            Y.append(l[i])
        elif a[i] == 3:
            Z.append(l[i])
    if len(X) == 0 or len(Y) == 0 or len(Z) == 0:
        continue
    else:
        a = 0
        a += 10*(len(X)+len(Y)+len(Z)-3)
        a += abs(A-sum(X)) + abs(B-sum(Y)) + abs(C-sum(Z))
        if a < ans:
            ans = a

print(ans)
