import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import product
from collections import Counter

n, a, b, c, *l = map(int, read().split())
ans = float('inf')
for bit in product([0, 1, 2, 3], repeat=n):
    if 0 not in bit or 1 not in bit or 2 not in bit:
        continue
    counter = Counter()
    memo = 0
    for ll, num in zip(l, bit):
        if num == 3:
            continue
        if counter[num] != 0:
            memo += 10
        counter[num] += ll
    ans = min(ans, abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo)
print(ans) import sys sys 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 sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from itertools import product from collections import Counter n, a, b, c, *l = map(int, read().split()) n map(int, read().split()) map int read().split() ().split () read split a b c *l l ans = float('inf') ans float('inf') float 'inf' for bit in product([0, 1, 2, 3], repeat=n):
    if 0 not in bit or 1 not in bit or 2 not in bit:
        continue
    counter = Counter()
    memo = 0
    for ll, num in zip(l, bit):
        if num == 3:
            continue
        if counter[num] != 0:
            memo += 10
        counter[num] += ll
    ans = min(ans, abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo) bit product([0, 1, 2, 3], repeat=n) product [0, 1, 2, 3] 0 1 2 3 repeat=n repeat n if 0 not in bit or 1 not in bit or 2 not in bit:
        continue
     0 not in bit or 1 not in bit or 2 not in bit 0 not in bit or 1 not in bit 0 not in bit 0 bit 1 not in bit 1 bit 2 not in bit 2 bit continue counter = Counter() counter Counter() Counter memo = 0 memo 0 for ll, num in zip(l, bit):
        if num == 3:
            continue
        if counter[num] != 0:
            memo += 10
        counter[num] += ll
     ll num zip(l, bit) zip l bit if num == 3:
            continue
         num == 3 num 3 continue if counter[num] != 0:
            memo += 10
         counter[num] != 0 counter[num] counter num 0 memo += 10 memo 10 counter[num] += ll counter[num] counter num ll ans = min(ans, abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo) ans min(ans, abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo) min ans abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) abs(counter[0] - a) + abs(counter[1] - b) abs(counter[0] - a) abs counter[0] - a counter[0] counter 0 a abs(counter[1] - b) abs counter[1] - b counter[1] counter 1 b abs(counter[2] - c) abs counter[2] - c counter[2] counter 2 c memo print(ans) print ans counter = Counter() Counter() counter memo = 0 0 memo a, b, c, *l = map(int, read().split()) map(int, read().split()) a c, *l = map(int, read().split()) map(int, read().split()) c readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline ans = min(ans, abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo) min(ans, abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo) ans b, c, *l = map(int, read().split()) map(int, read().split()) b n, a, b, c, *l = map(int, read().split()) map(int, read().split()) n memo += 10 10 memo read = sys.stdin.buffer.read sys.stdin.buffer.read read ans = float('inf') float('inf') ans
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import product
from collections import Counter

n, a, b, c, *l = map(int, read().split())
ans = float('inf')
for bit in product([0, 1, 2, 3], repeat=n):
    if 0 not in bit or 1 not in bit or 2 not in bit:
        continue
    counter = Counter()
    memo = 0
    for ll, num in zip(l, bit):
        if num == 3:
            continue
        if counter[num] != 0:
            memo += 10
        counter[num] += ll
    ans = min(ans, abs(counter[0] - a) + abs(counter[1] - b) + abs(counter[2] - c) + memo)
print(ans)
