import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**4
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B,C = LI()
    l = [NI() for _ in range(N)]
    x = [0] * 3
    ans = INF
    for p in itertools.combinations(range(N),3):
        q = []
        for i in range(N):
            if not i in p: q.append(i)
        for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

    print(ans)



if __name__ == '__main__':
    main() import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq def main():
    sys.setrecursionlimit(10**7)
    INF = 10**4
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B,C = LI()
    l = [NI() for _ in range(N)]
    x = [0] * 3
    ans = INF
    for p in itertools.combinations(range(N),3):
        q = []
        for i in range(N):
            if not i in p: q.append(i)
        for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

    print(ans) main sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**4 INF 10**4 10 4 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) NI lambda : int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline N,A,B,C = LI() N LI() LI A B C NI() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) NI() NI l = [NI() for _ in range(N)] l [NI() for _ in range(N)] x = [0] * 3 x [0] * 3 [0] 0 3 ans = INF ans INF for p in itertools.combinations(range(N),3):
        q = []
        for i in range(N):
            if not i in p: q.append(i)
        for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

     p itertools.combinations(range(N),3) itertools.combinations itertools combinations range(N) range N 3 q = [] q [] for i in range(N):
            if not i in p: q.append(i)
         i range(N) range N if not i in p: q.append(i)
         not i in p i in p i p for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

     i range(4**(N-3)) range 4**(N-3) 4 N-3 N 3 for j in range(3): x[j] = l[p[j]]
             j range(3) range 3 mp = 0 mp 0 r = i r i for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
             j range(N-3) range N-3 N 3 k = r % 4 k r % 4 r 4 if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                 k > 0 k 0 x[k-1] += l[q[j]] x[k-1] x k-1 k 1 l[q[j]] l q[j] q j mp += 10 mp 10 r //= 4 r 4 for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

     a b c itertools.permutations(x) itertools.permutations itertools permutations x ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c)) ans min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c)) min ans mp+abs(A-a)+abs(B-b)+abs(C-c) mp+abs(A-a)+abs(B-b) mp+abs(A-a) mp abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    sys.setrecursionlimit(10**7)
    INF = 10**4
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B,C = LI()
    l = [NI() for _ in range(N)]
    x = [0] * 3
    ans = INF
    for p in itertools.combinations(range(N),3):
        q = []
        for i in range(N):
            if not i in p: q.append(i)
        for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

    print(ans) def main():
    sys.setrecursionlimit(10**7)
    INF = 10**4
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B,C = LI()
    l = [NI() for _ in range(N)]
    x = [0] * 3
    ans = INF
    for p in itertools.combinations(range(N),3):
        q = []
        for i in range(N):
            if not i in p: q.append(i)
        for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

    print(ans) main
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**4
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B,C = LI()
    l = [NI() for _ in range(N)]
    x = [0] * 3
    ans = INF
    for p in itertools.combinations(range(N),3):
        q = []
        for i in range(N):
            if not i in p: q.append(i)
        for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

    print(ans)



if __name__ == '__main__':
    main()