# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Nは最大8まで、Aに使う竹はどれ？
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10 ** 5
for pattern in itertools.product(range(4), repeat=N):
    use = [0] * 3
    mp = 0
    for p, bam in zip(pattern, bamboo):
        if p == 3:
            continue
        if use[p] != 0:
            mp += 10
        use[p] += bam
    if use.count(0) != 0:
        continue
    mp += abs(A-use[0]) + abs(B-use[1]) + abs(C-use[2])
    if mp < answer:
        answer = mp

print(answer)
# 23 import sys sys import itertools itertools sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N, A, B, C = lr() N lr() lr A B C ir() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) ir() ir bamboo = [ir() for _ in range(N)] bamboo [ir() for _ in range(N)] answer = 10 ** 5 answer 10 ** 5 10 5 for pattern in itertools.product(range(4), repeat=N):
    use = [0] * 3
    mp = 0
    for p, bam in zip(pattern, bamboo):
        if p == 3:
            continue
        if use[p] != 0:
            mp += 10
        use[p] += bam
    if use.count(0) != 0:
        continue
    mp += abs(A-use[0]) + abs(B-use[1]) + abs(C-use[2])
    if mp < answer:
        answer = mp pattern itertools.product(range(4), repeat=N) itertools.product itertools product range(4) range 4 repeat=N repeat N use = [0] * 3 use [0] * 3 [0] 0 3 mp = 0 mp 0 for p, bam in zip(pattern, bamboo):
        if p == 3:
            continue
        if use[p] != 0:
            mp += 10
        use[p] += bam
     p bam zip(pattern, bamboo) zip pattern bamboo if p == 3:
            continue
         p == 3 p 3 continue if use[p] != 0:
            mp += 10
         use[p] != 0 use[p] use p 0 mp += 10 mp 10 use[p] += bam use[p] use p bam if use.count(0) != 0:
        continue
     use.count(0) != 0 use.count(0) use.count use count 0 0 continue mp += abs(A-use[0]) + abs(B-use[1]) + abs(C-use[2]) mp abs(A-use[0]) + abs(B-use[1]) + abs(C-use[2]) abs(A-use[0]) + abs(B-use[1]) abs(A-use[0]) abs A-use[0] A use[0] use 0 abs(B-use[1]) abs B-use[1] B use[1] use 1 abs(C-use[2]) abs C-use[2] C use[2] use 2 if mp < answer:
        answer = mp mp < answer mp answer answer = mp answer mp print(answer) print answer A, B, C = lr() lr() A B, C = lr() lr() B mp = 0 0 mp sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr N, A, B, C = lr() lr() N answer = 10 ** 5 10 ** 5 answer C = lr() lr() C ir = lambda: int(sr()) lambda: int(sr()) ir mp += abs(A-use[0]) + abs(B-use[1]) + abs(C-use[2]) abs(A-use[0]) + abs(B-use[1]) + abs(C-use[2]) mp answer = mp mp answer mp += 10 10 mp lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr use = [0] * 3 [0] * 3 use bamboo = [ir() for _ in range(N)] [ir() for _ in range(N)] bamboo
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Nは最大8まで、Aに使う竹はどれ？
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10 ** 5
for pattern in itertools.product(range(4), repeat=N):
    use = [0] * 3
    mp = 0
    for p, bam in zip(pattern, bamboo):
        if p == 3:
            continue
        if use[p] != 0:
            mp += 10
        use[p] += bam
    if use.count(0) != 0:
        continue
    mp += abs(A-use[0]) + abs(B-use[1]) + abs(C-use[2])
    if mp < answer:
        answer = mp

print(answer)
# 23