# 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本の竹それぞれA, B, C, 使わないか

N, A, B, C = lr()

bamboo = [ir() for _ in range(N)]

answer = 10 **  5

for pattern in itertools.product(list(range(4)), repeat=N):

    mp = 0

    Alist = []; Blist = []; Clist = []

    for i, p in enumerate(pattern):

        if p == 0:

            Alist.append(bamboo[i])

        elif p == 1:

            Blist.append(bamboo[i])

        elif p == 2:

            Clist.append(bamboo[i])

    if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0:

        continue

    mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3)

    mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist))

    if mp < answer:

        answer = mp



print(answer)

# 04
# 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(list(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
# 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本の竹それぞれA, B, C, 使わないか
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10**5
for pattern in itertools.product(list(range(4)), repeat=N):
    mp = 0
    Alist = []
    Blist = []
    Clist = []
    for i, p in enumerate(pattern):
        if p == 0:
            Alist.append(bamboo[i])
        elif p == 1:
            Blist.append(bamboo[i])
        elif p == 2:
            Clist.append(bamboo[i])
    if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0:
        continue
    mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3)
    mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist))
    if mp < answer:
        answer = mp
print(answer)
# 04

# 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(list(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

-# N本の竹それぞれA, B, C, 使わないか +# Nは最大8まで、Aに使う竹はどれ？ +    use = [0] * 3 -    Alist = [] -    Blist = [] -    Clist = [] -    for i, p in enumerate(pattern): -        if p == 0: -            Alist.append(bamboo[i]) -        elif p == 1: -            Blist.append(bamboo[i]) -        elif p == 2: -            Clist.append(bamboo[i]) -    if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 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: -    mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3) -    mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist)) +    mp += abs(A - use[0]) + abs(B - use[1]) + abs(C - use[2]) -# 04 +# 23