from itertools import product
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
t1 = set([0,1,2,3])
t2= set([1,2,3])
def calc(t):
    t3 = set(t)
    if not (t3 == t1 or t3 == t2): return INF
    a, b, c = 0, 0, 0
    cnt = 0
    for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
    return abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10

ans = 10 ** 9
# 4進数の配列を生成する
# 0:未使用,1:aに使用,2:bに使用,3:cに使用
for p in product(range(4), repeat=N):
    ans = min(ans, calc(p))

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 i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input l = [int(input()) for i in range(N)] l [int(input()) for i in range(N)] INF = 10 ** 9 INF 10 ** 9 10 9 t1 = set([0,1,2,3]) t1 set([0,1,2,3]) set [0,1,2,3] 0 1 2 3 t2= set([1,2,3]) t2 set([1,2,3]) set [1,2,3] 1 2 3 def calc(t):
    t3 = set(t)
    if not (t3 == t1 or t3 == t2): return INF
    a, b, c = 0, 0, 0
    cnt = 0
    for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
    return abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10 calc t3 = set(t) t3 set(t) set t if not (t3 == t1 or t3 == t2): return INF
     not (t3 == t1 or t3 == t2) t3 == t1 or t3 == t2 t3 == t1 t3 t1 t3 == t2 t3 t2 a, b, c = 0, 0, 0 a 0 b 0 c 0 cnt = 0 cnt 0 for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
     i v enumerate(t) enumerate t if v != 0: cnt += 1
         v != 0 v 0 if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
     v == 1 v 1 elif v == 2: b += l[i]
         v == 2 v 2 elif v == 3: c += l[i]
     v == 3 v 3 return abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10 abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10 abs(a-A) + abs(b-B) + abs(c-C) abs(a-A) + abs(b-B) abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C (cnt-3) * 10 cnt-3 cnt 3 10 t t ans = 10 ** 9 ans 10 ** 9 10 9 for p in product(range(4), repeat=N):
    ans = min(ans, calc(p)) p product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N ans = min(ans, calc(p)) ans min(ans, calc(p)) min ans calc(p) calc p print(ans) print ans l = [int(input()) for i in range(N)] [int(input()) for i in range(N)] l INF = 10 ** 9 10 ** 9 INF def calc(t):
    t3 = set(t)
    if not (t3 == t1 or t3 == t2): return INF
    a, b, c = 0, 0, 0
    cnt = 0
    for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
    return abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10 def calc(t):
    t3 = set(t)
    if not (t3 == t1 or t3 == t2): return INF
    a, b, c = 0, 0, 0
    cnt = 0
    for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
    return abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10 calc t1 = set([0,1,2,3]) set([0,1,2,3]) t1 ans = min(ans, calc(p)) min(ans, calc(p)) ans t2= set([1,2,3]) set([1,2,3]) t2 N, A, B, C = map(int, input().split()) map(int, input().split()) N B, C = map(int, input().split()) map(int, input().split()) B C = map(int, input().split()) map(int, input().split()) C ans = 10 ** 9 10 ** 9 ans A, B, C = map(int, input().split()) map(int, input().split()) A
from itertools import product
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
t1 = set([0,1,2,3])
t2= set([1,2,3])
def calc(t):
    t3 = set(t)
    if not (t3 == t1 or t3 == t2): return INF
    a, b, c = 0, 0, 0
    cnt = 0
    for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
    return abs(a-A) + abs(b-B) + abs(c-C) + (cnt-3) * 10

ans = 10 ** 9
# 4進数の配列を生成する
# 0:未使用,1:aに使用,2:bに使用,3:cに使用
for p in product(range(4), repeat=N):
    ans = min(ans, calc(p))

print(ans)

