from itertools import product
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 1001001001
for x in product(range(4), repeat=n):
    s = [0] * 4
    t = -3
    for i in range(n):
        t += x[i] < 3
        s[x[i]] += l[i]
    s.pop()
    if 0 in s:
        continue
    ans = min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c))
print(ans) from itertools import product n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] ans = 1001001001 ans 1001001001 for x in product(range(4), repeat=n):
    s = [0] * 4
    t = -3
    for i in range(n):
        t += x[i] < 3
        s[x[i]] += l[i]
    s.pop()
    if 0 in s:
        continue
    ans = min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c)) x product(range(4), repeat=n) product range(4) range 4 repeat=n repeat n s = [0] * 4 s [0] * 4 [0] 0 4 t = -3 t -3 for i in range(n):
        t += x[i] < 3
        s[x[i]] += l[i]
     i range(n) range n t += x[i] < 3 t x[i] < 3 x[i] x i 3 s[x[i]] += l[i] s[x[i]] s x[i] x i l[i] l i s.pop() s.pop s pop if 0 in s:
        continue
     0 in s 0 s continue ans = min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c)) ans min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c)) min ans t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c) t * 10 + abs(s[0] - a) + abs(s[1] - b) t * 10 + abs(s[0] - a) t * 10 t 10 abs(s[0] - a) abs s[0] - a s[0] s 0 a abs(s[1] - b) abs s[1] - b s[1] s 1 b abs(s[2] - c) abs s[2] - c s[2] s 2 c print(ans) print ans ans = 1001001001 1001001001 ans l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l a, b, c = map(int, input().split()) map(int, input().split()) a b, c = map(int, input().split()) map(int, input().split()) b ans = min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c)) min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c)) ans c = map(int, input().split()) map(int, input().split()) c s = [0] * 4 [0] * 4 s n, a, b, c = map(int, input().split()) map(int, input().split()) n t = -3 -3 t t += x[i] < 3 x[i] < 3 t
from itertools import product
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 1001001001
for x in product(range(4), repeat=n):
    s = [0] * 4
    t = -3
    for i in range(n):
        t += x[i] < 3
        s[x[i]] += l[i]
    s.pop()
    if 0 in s:
        continue
    ans = min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c))
print(ans)
