import itertools
n, a, b, c = map(int, input().split())
lis = []
for i in range(n):
    lis.append(int(input()))

res = 10**9

for g in itertools.product([0, 1, 2, 3], repeat=n):
    s = [[], [], [], []]
    for i, gg in enumerate(g):
        s[gg].append(lis[i])
    if not s[0] or not s[1] or not s[2]:
        continue
    else:
        x, y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])])
        l, m, n = len(s[0]), len(s[1]), len(s[2])
        pnt = abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3)
        res = min(pnt, res)
print(res) import itertools itertools n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c lis = [] lis [] for i in range(n):
    lis.append(int(input())) i range(n) range n lis.append(int(input())) lis.append lis append int(input()) int input() input res = 10**9 res 10**9 10 9 for g in itertools.product([0, 1, 2, 3], repeat=n):
    s = [[], [], [], []]
    for i, gg in enumerate(g):
        s[gg].append(lis[i])
    if not s[0] or not s[1] or not s[2]:
        continue
    else:
        x, y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])])
        l, m, n = len(s[0]), len(s[1]), len(s[2])
        pnt = abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3)
        res = min(pnt, res) g itertools.product([0, 1, 2, 3], repeat=n) itertools.product itertools product [0, 1, 2, 3] 0 1 2 3 repeat=n repeat n s = [[], [], [], []] s [[], [], [], []] [] [] [] [] for i, gg in enumerate(g):
        s[gg].append(lis[i])
     i gg enumerate(g) enumerate g s[gg].append(lis[i]) [gg].append [gg] s gg append lis[i] lis i if not s[0] or not s[1] or not s[2]:
        continue
    else:
        x, y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])])
        l, m, n = len(s[0]), len(s[1]), len(s[2])
        pnt = abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3)
        res = min(pnt, res) not s[0] or not s[1] or not s[2] not s[0] or not s[1] not s[0] s[0] s 0 not s[1] s[1] s 1 not s[2] s[2] s 2 continue x, y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])]) x sorted([sum(s[0]), sum(s[1]), sum(s[2])]) sorted [sum(s[0]), sum(s[1]), sum(s[2])] sum(s[0]) sum s[0] s 0 sum(s[1]) sum s[1] s 1 sum(s[2]) sum s[2] s 2 y z l, m, n = len(s[0]), len(s[1]), len(s[2]) l len(s[0]) len s[0] s 0 m len(s[1]) len s[1] s 1 n len(s[2]) len s[2] s 2 pnt = abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3) pnt abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3) abs(x-c) + abs(y-b) + abs(z-a) abs(x-c) + abs(y-b) abs(x-c) abs x-c x c abs(y-b) abs y-b y b abs(z-a) abs z-a z a 10*(l+m+n-3) 10 l+m+n-3 l+m+n l+m l m n 3 res = min(pnt, res) res min(pnt, res) min pnt res print(res) print res res = min(pnt, res) min(pnt, res) res pnt = abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3) abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3) pnt s = [[], [], [], []] [[], [], [], []] s a, b, c = map(int, input().split()) map(int, input().split()) a m, n = len(s[0]), len(s[1]), len(s[2]) len(s[1]) m n = len(s[0]), len(s[1]), len(s[2]) len(s[2]) n b, c = map(int, input().split()) map(int, input().split()) b z = sorted([sum(s[0]), sum(s[1]), sum(s[2])]) sorted([sum(s[0]), sum(s[1]), sum(s[2])]) z n, a, b, c = map(int, input().split()) map(int, input().split()) n l, m, n = len(s[0]), len(s[1]), len(s[2]) len(s[0]) l y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])]) sorted([sum(s[0]), sum(s[1]), sum(s[2])]) y c = map(int, input().split()) map(int, input().split()) c lis = [] [] lis x, y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])]) sorted([sum(s[0]), sum(s[1]), sum(s[2])]) x res = 10**9 10**9 res
import itertools
n, a, b, c = map(int, input().split())
lis = []
for i in range(n):
    lis.append(int(input()))

res = 10**9

for g in itertools.product([0, 1, 2, 3], repeat=n):
    s = [[], [], [], []]
    for i, gg in enumerate(g):
        s[gg].append(lis[i])
    if not s[0] or not s[1] or not s[2]:
        continue
    else:
        x, y, z = sorted([sum(s[0]), sum(s[1]), sum(s[2])])
        l, m, n = len(s[0]), len(s[1]), len(s[2])
        pnt = abs(x-c) + abs(y-b) + abs(z-a) + 10*(l+m+n-3)
        res = min(pnt, res)
print(res)
