import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,a,b,c=MI()
mn=inf
lis=[I() for i in range(n)]
for i in list(product([0,1,2,3],repeat=n)):
    x=[]
    y=[]
    z=[]
    for j in range(n):
        if i[j]==0:
            x.append(lis[j])
        elif i[j]==1:
            y.append(lis[j])
        elif i[j]==2:
            z.append(lis[j])
    if len(x)==0 or len(y)==0 or len(z)==0:
        ans=inf
    else:
        ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1)
    #print(ans)
    if ans<mn:
        mn=ans
        X=x
        Y=y
        Z=z
print(mn)
'''print(X)
print(Y)
print(Z)
''' import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI 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 def LI2(): return [int(input()) for i in range(n)] LI2 [LI()]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [LI()] LI() LI def MXI(): return [[LI()]for i in range(n)] MXI def SI(): return input().rstrip() SI def printns(x): print('\n'.join(x)) printns x x def printni(x): print('\n'.join(list(map(str,x)))) printni x x inf = 10**17 inf 10**17 10 17 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 n,a,b,c=MI() n MI() MI a b c mn=inf mn inf I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I lis=[I() for i in range(n)] lis [I() for i in range(n)] for i in list(product([0,1,2,3],repeat=n)):
    x=[]
    y=[]
    z=[]
    for j in range(n):
        if i[j]==0:
            x.append(lis[j])
        elif i[j]==1:
            y.append(lis[j])
        elif i[j]==2:
            z.append(lis[j])
    if len(x)==0 or len(y)==0 or len(z)==0:
        ans=inf
    else:
        ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1)
    #print(ans)
    if ans<mn:
        mn=ans
        X=x
        Y=y
        Z=z i list(product([0,1,2,3],repeat=n)) list product([0,1,2,3],repeat=n) product [0,1,2,3] 0 1 2 3 repeat=n repeat n x=[] x [] y=[] y [] z=[] z [] for j in range(n):
        if i[j]==0:
            x.append(lis[j])
        elif i[j]==1:
            y.append(lis[j])
        elif i[j]==2:
            z.append(lis[j])
     j range(n) range n if i[j]==0:
            x.append(lis[j])
        elif i[j]==1:
            y.append(lis[j])
        elif i[j]==2:
            z.append(lis[j])
     i[j]==0 i[j] i j 0 x.append(lis[j]) x.append x append lis[j] lis j elif i[j]==1:
            y.append(lis[j])
         i[j]==1 i[j] i j 1 y.append(lis[j]) y.append y append lis[j] lis j elif i[j]==2:
            z.append(lis[j])
     i[j]==2 i[j] i j 2 z.append(lis[j]) z.append z append lis[j] lis j if len(x)==0 or len(y)==0 or len(z)==0:
        ans=inf
    else:
        ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1)
    #print(ans)
     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 ans=inf ans inf ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1) ans abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1) abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c) abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1) abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b) abs(sum(x)-a)+10*(len(x)-1) abs(sum(x)-a) abs sum(x)-a sum(x) sum x a 10*(len(x)-1) 10 len(x)-1 len(x) len x 1 abs(sum(y)-b) abs sum(y)-b sum(y) sum y b 10*(len(y)-1) 10 len(y)-1 len(y) len y 1 abs(sum(z)-c) abs sum(z)-c sum(z) sum z c 10*(len(z)-1) 10 len(z)-1 len(z) len z 1 if ans<mn:
        mn=ans
        X=x
        Y=y
        Z=z ans<mn ans mn mn=ans mn ans X=x X x Y=y Y y Z=z Z z print(mn) print mn '''print(X)
print(Y)
print(Z)
''' mn=ans ans mn a,b,c=MI() MI() a def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI n,a,b,c=MI() MI() n mn=inf inf mn inf = 10**17 10**17 inf y=[] [] y def MXI(): return [[LI()]for i in range(n)] def MXI(): return [[LI()]for i in range(n)] MXI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI mod = 10**9 + 7 10**9 + 7 mod ans=inf inf ans x=[] [] x c=MI() MI() c def printns(x): print('\n'.join(x)) def printns(x): print('\n'.join(x)) printns ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1) abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1) ans def SI(): return input().rstrip() def SI(): return input().rstrip() SI b,c=MI() MI() b X=x x X Z=z z Z input = sys.stdin.readline sys.stdin.readline input def printni(x): print('\n'.join(list(map(str,x)))) def printni(x): print('\n'.join(list(map(str,x)))) printni def LI2(): return [int(input()) for i in range(n)] def LI2(): return [int(input()) for i in range(n)] LI2 z=[] [] z Y=y y Y lis=[I() for i in range(n)] [I() for i in range(n)] lis def I(): return int(input()) def I(): return int(input()) I
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,a,b,c=MI()
mn=inf
lis=[I() for i in range(n)]
for i in list(product([0,1,2,3],repeat=n)):
    x=[]
    y=[]
    z=[]
    for j in range(n):
        if i[j]==0:
            x.append(lis[j])
        elif i[j]==1:
            y.append(lis[j])
        elif i[j]==2:
            z.append(lis[j])
    if len(x)==0 or len(y)==0 or len(z)==0:
        ans=inf
    else:
        ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1)
    #print(ans)
    if ans<mn:
        mn=ans
        X=x
        Y=y
        Z=z
print(mn)
'''print(X)
print(Y)
print(Z)
'''