def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    N, A, B, C = LI()
    L = [I()for _ in range(N)]
    loop = (1<<(2*N))
    ans = inf
    for l in range(loop):
        cost = 0
        bamboo_A = 0
        bamboo_B = 0
        bamboo_C = 0
        for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
        if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
        cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30
        ans = min(ans,cost)

    print(ans)
    return

def examD():
    N = I()
    P = LI()
    O_ = [-1]*N
    start = P[0]-1
    for i in range(N):
        O_[P[i]-1] = i
    #print(O_,start)
    A = [1]*N
    B = [1]*N
    for i in range(start+1,N):
        cur = O_[i]-O_[i-1]
        if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
    for i in range(start)[::-1]:
        cur = O_[i]-O_[i+1]
        if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
    if A[0]<1:
        add = (1-A[0])
        for i in range(N):
            A[i] += add
    if B[-1]<1:
        add = (1-B[-1])
        for i in range(N):
            B[i] += add

    print(" ".join(map(str,A)))
    print(" ".join(map(str,B)))
    return

def examE():
    return

def examF():
    ans = 0
    print(ans)
    return


from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
9
7 3 9 1 8 4 5 6 2
""" def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return examA N = DI()/dec(7) N DI()/dec(7) DI() DI dec(7) dec 7 ans = N ans N print(N) print N return def examB():
    ans = 0
    print(ans)
    return examB ans = 0 ans 0 print(ans) print ans return def examC():
    N, A, B, C = LI()
    L = [I()for _ in range(N)]
    loop = (1<<(2*N))
    ans = inf
    for l in range(loop):
        cost = 0
        bamboo_A = 0
        bamboo_B = 0
        bamboo_C = 0
        for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
        if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
        cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30
        ans = min(ans,cost)

    print(ans)
    return examC N, A, B, C = LI() N LI() LI A B C I()for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) I() I L = [I()for _ in range(N)] L [I()for _ in range(N)] loop = (1<<(2*N)) loop 1<<(2*N) 1 2*N 2 N ans = inf ans inf for l in range(loop):
        cost = 0
        bamboo_A = 0
        bamboo_B = 0
        bamboo_C = 0
        for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
        if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
        cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30
        ans = min(ans,cost)

     l range(loop) range loop cost = 0 cost 0 bamboo_A = 0 bamboo_A 0 bamboo_B = 0 bamboo_B 0 bamboo_C = 0 bamboo_C 0 for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
         j range(N) range N if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
         l&(1<<(2*j))>0 l&(1<<(2*j)) l 1<<(2*j) 1 2*j 2 j 0 if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
             l&(1<<(2*j+1))>0 l&(1<<(2*j+1)) l 1<<(2*j+1) 1 2*j+1 2*j 2 j 1 0 cost += 10 cost 10 bamboo_A += L[j] bamboo_A L[j] L j cost += 10 cost 10 bamboo_B += L[j] bamboo_B L[j] L j if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
         l&(1<<(2*j+1))>0 l&(1<<(2*j+1)) l 1<<(2*j+1) 1 2*j+1 2*j 2 j 1 0 cost += 10 cost 10 bamboo_C += L[j] bamboo_C L[j] L j if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
         bamboo_A==0 or bamboo_B==0 or bamboo_C==0 bamboo_A==0 or bamboo_B==0 bamboo_A==0 bamboo_A 0 bamboo_B==0 bamboo_B 0 bamboo_C==0 bamboo_C 0 continue cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30 cost abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30 abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) abs(A-bamboo_A) + abs(B-bamboo_B) abs(A-bamboo_A) abs A-bamboo_A A bamboo_A abs(B-bamboo_B) abs B-bamboo_B B bamboo_B abs(C-bamboo_C) abs C-bamboo_C C bamboo_C 30 ans = min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans return def examD():
    N = I()
    P = LI()
    O_ = [-1]*N
    start = P[0]-1
    for i in range(N):
        O_[P[i]-1] = i
    #print(O_,start)
    A = [1]*N
    B = [1]*N
    for i in range(start+1,N):
        cur = O_[i]-O_[i-1]
        if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
    for i in range(start)[::-1]:
        cur = O_[i]-O_[i+1]
        if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
    if A[0]<1:
        add = (1-A[0])
        for i in range(N):
            A[i] += add
    if B[-1]<1:
        add = (1-B[-1])
        for i in range(N):
            B[i] += add

    print(" ".join(map(str,A)))
    print(" ".join(map(str,B)))
    return examD N = I() N I() I P = LI() P LI() LI O_ = [-1]*N O_ [-1]*N [-1] -1 N start = P[0]-1 start P[0]-1 P[0] P 0 1 for i in range(N):
        O_[P[i]-1] = i
    #print(O_,start)
     i range(N) range N O_[P[i]-1] = i O_[P[i]-1] O_ P[i]-1 P[i] P i 1 i A = [1]*N A [1]*N [1] 1 N B = [1]*N B [1]*N [1] 1 N for i in range(start+1,N):
        cur = O_[i]-O_[i-1]
        if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
     i range(start+1,N) range start+1 start 1 N cur = O_[i]-O_[i-1] cur O_[i]-O_[i-1] O_[i] O_ i O_[i-1] O_ i-1 i 1 if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
     cur>0 cur 0 A[i] = A[i-1] + (cur+1) A[i] A i A[i-1] + (cur+1) A[i-1] A i-1 i 1 cur+1 cur 1 B[i] = B[i-1] - 1 B[i] B i B[i-1] - 1 B[i-1] B i-1 i 1 1 A[i] = A[i-1] + 1 A[i] A i A[i-1] + 1 A[i-1] A i-1 i 1 1 B[i] = B[i-1] - (-cur+1) B[i] B i B[i-1] - (-cur+1) B[i-1] B i-1 i 1 -cur+1 -cur cur 1 for i in range(start)[::-1]:
        cur = O_[i]-O_[i+1]
        if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
     i range(start)[::-1] (start) range start ::-1 -1 cur = O_[i]-O_[i+1] cur O_[i]-O_[i+1] O_[i] O_ i O_[i+1] O_ i+1 i 1 if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
     cur>0 cur 0 B[i] = B[i+1] + (cur+1) B[i] B i B[i+1] + (cur+1) B[i+1] B i+1 i 1 cur+1 cur 1 A[i] = A[i+1] - 1 A[i] A i A[i+1] - 1 A[i+1] A i+1 i 1 1 B[i] = B[i+1] + 1 B[i] B i B[i+1] + 1 B[i+1] B i+1 i 1 1 A[i] = A[i+1] - (-cur+1) A[i] A i A[i+1] - (-cur+1) A[i+1] A i+1 i 1 -cur+1 -cur cur 1 if A[0]<1:
        add = (1-A[0])
        for i in range(N):
            A[i] += add
     A[0]<1 A[0] A 0 1 add = (1-A[0]) add 1-A[0] 1 A[0] A 0 for i in range(N):
            A[i] += add
     i range(N) range N A[i] += add A[i] A i add if B[-1]<1:
        add = (1-B[-1])
        for i in range(N):
            B[i] += add

     B[-1]<1 B[-1] B -1 1 add = (1-B[-1]) add 1-B[-1] 1 B[-1] B -1 for i in range(N):
            B[i] += add

     i range(N) range N B[i] += add B[i] B i add print(" ".join(map(str,A))) print " ".join(map(str,A)) " ".join " " join map(str,A) map str A print(" ".join(map(str,B))) print " ".join(map(str,B)) " ".join " " join map(str,B) map str B return def examE():
    return examE return def examF():
    ans = 0
    print(ans)
    return examF ans = 0 ans 0 print(ans) print ans return from decimal import getcontext,Decimal as dec import sys,bisect,itertools,heapq,math,random sys bisect itertools heapq math random from copy import deepcopy from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines def I(): return int(input()) I def LI(): return list(map(int,sys.stdin.readline().split())) LI def DI(): return dec(input()) DI def LDI(): return list(map(dec,sys.stdin.readline().split())) LDI def LSI(): return list(map(str,sys.stdin.readline().split())) LSI def LS(): return sys.stdin.readline().split() LS def SI(): return sys.stdin.readline().strip() SI global mod,mod2,inf,alphabet,_ep mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 mod2 = 998244353 mod2 998244353 inf = 10**18 inf 10**18 10 18 _ep = dec("0.000000000001") _ep dec("0.000000000001") dec "0.000000000001" chr(ord('a') + i) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(ord('a') + i) chr ord('a') + i ord('a') ord 'a' i alphabet = [chr(ord('a') + i) for i in range(26)] alphabet [chr(ord('a') + i) for i in range(26)] chr(ord('a') + i): i for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(ord('a') + i) chr ord('a') + i ord('a') ord 'a' i i alphabet_convert = {chr(ord('a') + i): i for i in range(26)} alphabet_convert {chr(ord('a') + i): i for i in range(26)} getcontext().prec = 28 getcontext().prec () getcontext prec 28 sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 if __name__ == '__main__':
    examC() __name__ == '__main__' __name__ '__main__' examC() examC """
9
7 3 9 1 8 4 5 6 2
""" def examB():
    ans = 0
    print(ans)
    return def examB():
    ans = 0
    print(ans)
    return examB def examE():
    return def examE():
    return examE global mod,mod2,inf,alphabet,_ep def SI(): return sys.stdin.readline().strip() def SI(): return sys.stdin.readline().strip() SI def LI(): return list(map(int,sys.stdin.readline().split())) def LI(): return list(map(int,sys.stdin.readline().split())) LI def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return examA readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines def LSI(): return list(map(str,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) LSI def DI(): return dec(input()) def DI(): return dec(input()) DI _ep = dec("0.000000000001") dec("0.000000000001") _ep def LDI(): return list(map(dec,sys.stdin.readline().split())) def LDI(): return list(map(dec,sys.stdin.readline().split())) LDI alphabet_convert = {chr(ord('a') + i): i for i in range(26)} {chr(ord('a') + i): i for i in range(26)} alphabet_convert inf = 10**18 10**18 inf mod2 = 998244353 998244353 mod2 def I(): return int(input()) def I(): return int(input()) I def examD():
    N = I()
    P = LI()
    O_ = [-1]*N
    start = P[0]-1
    for i in range(N):
        O_[P[i]-1] = i
    #print(O_,start)
    A = [1]*N
    B = [1]*N
    for i in range(start+1,N):
        cur = O_[i]-O_[i-1]
        if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
    for i in range(start)[::-1]:
        cur = O_[i]-O_[i+1]
        if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
    if A[0]<1:
        add = (1-A[0])
        for i in range(N):
            A[i] += add
    if B[-1]<1:
        add = (1-B[-1])
        for i in range(N):
            B[i] += add

    print(" ".join(map(str,A)))
    print(" ".join(map(str,B)))
    return def examD():
    N = I()
    P = LI()
    O_ = [-1]*N
    start = P[0]-1
    for i in range(N):
        O_[P[i]-1] = i
    #print(O_,start)
    A = [1]*N
    B = [1]*N
    for i in range(start+1,N):
        cur = O_[i]-O_[i-1]
        if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
    for i in range(start)[::-1]:
        cur = O_[i]-O_[i+1]
        if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
    if A[0]<1:
        add = (1-A[0])
        for i in range(N):
            A[i] += add
    if B[-1]<1:
        add = (1-B[-1])
        for i in range(N):
            B[i] += add

    print(" ".join(map(str,A)))
    print(" ".join(map(str,B)))
    return examD alphabet = [chr(ord('a') + i) for i in range(26)] [chr(ord('a') + i) for i in range(26)] alphabet read = sys.stdin.buffer.read sys.stdin.buffer.read read def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS def examC():
    N, A, B, C = LI()
    L = [I()for _ in range(N)]
    loop = (1<<(2*N))
    ans = inf
    for l in range(loop):
        cost = 0
        bamboo_A = 0
        bamboo_B = 0
        bamboo_C = 0
        for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
        if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
        cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30
        ans = min(ans,cost)

    print(ans)
    return def examC():
    N, A, B, C = LI()
    L = [I()for _ in range(N)]
    loop = (1<<(2*N))
    ans = inf
    for l in range(loop):
        cost = 0
        bamboo_A = 0
        bamboo_B = 0
        bamboo_C = 0
        for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
        if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
        cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30
        ans = min(ans,cost)

    print(ans)
    return examC readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def examF():
    ans = 0
    print(ans)
    return def examF():
    ans = 0
    print(ans)
    return examF mod = 10**9 + 7 10**9 + 7 mod
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    N, A, B, C = LI()
    L = [I()for _ in range(N)]
    loop = (1<<(2*N))
    ans = inf
    for l in range(loop):
        cost = 0
        bamboo_A = 0
        bamboo_B = 0
        bamboo_C = 0
        for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
        if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
        cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30
        ans = min(ans,cost)

    print(ans)
    return

def examD():
    N = I()
    P = LI()
    O_ = [-1]*N
    start = P[0]-1
    for i in range(N):
        O_[P[i]-1] = i
    #print(O_,start)
    A = [1]*N
    B = [1]*N
    for i in range(start+1,N):
        cur = O_[i]-O_[i-1]
        if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
    for i in range(start)[::-1]:
        cur = O_[i]-O_[i+1]
        if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
    if A[0]<1:
        add = (1-A[0])
        for i in range(N):
            A[i] += add
    if B[-1]<1:
        add = (1-B[-1])
        for i in range(N):
            B[i] += add

    print(" ".join(map(str,A)))
    print(" ".join(map(str,B)))
    return

def examE():
    return

def examF():
    ans = 0
    print(ans)
    return


from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
9
7 3 9 1 8 4 5 6 2
"""