import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, a, b, c = map(int, readline().split())
l = [int(readline()) for _ in range(n)]

ans = float('inf')
for pattern in itertools.product(range(4), repeat=n):
    cnt = [0] * 4
    length = [0] * 4
    mp = 0
    for i, v in enumerate(pattern):
        if cnt[v] != 0 and 0 <= v <= 2:
            mp += 10
        cnt[v] += 1
        length[v] += l[i]
    if cnt[0] > 0 and cnt[1] > 0 and cnt[2] > 0:
        mp += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2])
        ans = min(ans, mp)

print(ans) import sys sys import itertools itertools 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 n, a, b, c = map(int, readline().split()) n map(int, readline().split()) map int readline().split() ().split () readline split a b c int(readline()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(readline()) int readline() readline l = [int(readline()) for _ in range(n)] l [int(readline()) for _ in range(n)] ans = float('inf') ans float('inf') float 'inf' for pattern in itertools.product(range(4), repeat=n):
    cnt = [0] * 4
    length = [0] * 4
    mp = 0
    for i, v in enumerate(pattern):
        if cnt[v] != 0 and 0 <= v <= 2:
            mp += 10
        cnt[v] += 1
        length[v] += l[i]
    if cnt[0] > 0 and cnt[1] > 0 and cnt[2] > 0:
        mp += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2])
        ans = min(ans, mp) pattern itertools.product(range(4), repeat=n) itertools.product itertools product range(4) range 4 repeat=n repeat n cnt = [0] * 4 cnt [0] * 4 [0] 0 4 length = [0] * 4 length [0] * 4 [0] 0 4 mp = 0 mp 0 for i, v in enumerate(pattern):
        if cnt[v] != 0 and 0 <= v <= 2:
            mp += 10
        cnt[v] += 1
        length[v] += l[i]
     i v enumerate(pattern) enumerate pattern if cnt[v] != 0 and 0 <= v <= 2:
            mp += 10
         cnt[v] != 0 and 0 <= v <= 2 cnt[v] != 0 cnt[v] cnt v 0 0 <= v <= 2 0 <= v 0 v 2 mp += 10 mp 10 cnt[v] += 1 cnt[v] cnt v 1 length[v] += l[i] length[v] length v l[i] l i if cnt[0] > 0 and cnt[1] > 0 and cnt[2] > 0:
        mp += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2])
        ans = min(ans, mp) cnt[0] > 0 and cnt[1] > 0 and cnt[2] > 0 cnt[0] > 0 and cnt[1] > 0 cnt[0] > 0 cnt[0] cnt 0 0 cnt[1] > 0 cnt[1] cnt 1 0 cnt[2] > 0 cnt[2] cnt 2 0 mp += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2]) mp abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2]) abs(a - length[0]) + abs(b - length[1]) abs(a - length[0]) abs a - length[0] a length[0] length 0 abs(b - length[1]) abs b - length[1] b length[1] length 1 abs(c - length[2]) abs c - length[2] c length[2] length 2 ans = min(ans, mp) ans min(ans, mp) min ans mp print(ans) print ans l = [int(readline()) for _ in range(n)] [int(readline()) for _ in range(n)] l mp = 0 0 mp read = sys.stdin.buffer.read sys.stdin.buffer.read read readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline ans = float('inf') float('inf') ans mp += 10 10 mp cnt = [0] * 4 [0] * 4 cnt ans = min(ans, mp) min(ans, mp) ans b, c = map(int, readline().split()) map(int, readline().split()) b n, a, b, c = map(int, readline().split()) map(int, readline().split()) n readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines c = map(int, readline().split()) map(int, readline().split()) c mp += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2]) abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2]) mp a, b, c = map(int, readline().split()) map(int, readline().split()) a length = [0] * 4 [0] * 4 length
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, a, b, c = map(int, readline().split())
l = [int(readline()) for _ in range(n)]

ans = float('inf')
for pattern in itertools.product(range(4), repeat=n):
    cnt = [0] * 4
    length = [0] * 4
    mp = 0
    for i, v in enumerate(pattern):
        if cnt[v] != 0 and 0 <= v <= 2:
            mp += 10
        cnt[v] += 1
        length[v] += l[i]
    if cnt[0] > 0 and cnt[1] > 0 and cnt[2] > 0:
        mp += abs(a - length[0]) + abs(b - length[1]) + abs(c - length[2])
        ans = min(ans, mp)

print(ans)