def f(i):
    global ans
    if i == n:
        w, x, y, z = 0, 0, 0, 0
        for i in range(n):
            if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
        if x > 0 and y > 0 and z > 0:
            mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3)
            ans = min(ans, mp)
        return
    s[i] = 0
    f(i + 1)
    s[i] = 1
    f(i + 1)
    s[i] = 2
    f(i + 1)
    s[i] = 3
    f(i + 1)

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
s = [3] * n
ans = 114514
f(0)
print(ans) def f(i):
    global ans
    if i == n:
        w, x, y, z = 0, 0, 0, 0
        for i in range(n):
            if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
        if x > 0 and y > 0 and z > 0:
            mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3)
            ans = min(ans, mp)
        return
    s[i] = 0
    f(i + 1)
    s[i] = 1
    f(i + 1)
    s[i] = 2
    f(i + 1)
    s[i] = 3
    f(i + 1) f global ans if i == n:
        w, x, y, z = 0, 0, 0, 0
        for i in range(n):
            if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
        if x > 0 and y > 0 and z > 0:
            mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3)
            ans = min(ans, mp)
        return
     i == n i n w, x, y, z = 0, 0, 0, 0 w 0 x 0 y 0 z 0 for i in range(n):
            if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
         i range(n) range n if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
         s[i] == 1 s[i] s i 1 x += l[i] x l[i] l i elif s[i] == 2:
                y += l[i]
             s[i] == 2 s[i] s i 2 y += l[i] y l[i] l i elif s[i] == 3:
                z += l[i]
             s[i] == 3 s[i] s i 3 z += l[i] z l[i] l i w += 1 w 1 if x > 0 and y > 0 and z > 0:
            mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3)
            ans = min(ans, mp)
         x > 0 and y > 0 and z > 0 x > 0 and y > 0 x > 0 x 0 y > 0 y 0 z > 0 z 0 mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3) mp abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3) abs(a - x) + abs(b - y) + abs(c - z) abs(a - x) + abs(b - y) abs(a - x) abs a - x a x abs(b - y) abs b - y b y abs(c - z) abs c - z c z 10 * (n - w - 3) 10 n - w - 3 n - w n w 3 ans = min(ans, mp) ans min(ans, mp) min ans mp return s[i] = 0 s[i] s i 0 f(i + 1) f i + 1 i 1 s[i] = 1 s[i] s i 1 f(i + 1) f i + 1 i 1 s[i] = 2 s[i] s i 2 f(i + 1) f i + 1 i 1 s[i] = 3 s[i] s i 3 f(i + 1) f i + 1 i 1 i i 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)] s = [3] * n s [3] * n [3] 3 n ans = 114514 ans 114514 f(0) f 0 print(ans) print ans a, b, c = map(int, input().split()) map(int, input().split()) a b, c = map(int, input().split()) map(int, input().split()) b s = [3] * n [3] * n s l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l ans = 114514 114514 ans n, a, b, c = map(int, input().split()) map(int, input().split()) n def f(i):
    global ans
    if i == n:
        w, x, y, z = 0, 0, 0, 0
        for i in range(n):
            if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
        if x > 0 and y > 0 and z > 0:
            mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3)
            ans = min(ans, mp)
        return
    s[i] = 0
    f(i + 1)
    s[i] = 1
    f(i + 1)
    s[i] = 2
    f(i + 1)
    s[i] = 3
    f(i + 1) def f(i):
    global ans
    if i == n:
        w, x, y, z = 0, 0, 0, 0
        for i in range(n):
            if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
        if x > 0 and y > 0 and z > 0:
            mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3)
            ans = min(ans, mp)
        return
    s[i] = 0
    f(i + 1)
    s[i] = 1
    f(i + 1)
    s[i] = 2
    f(i + 1)
    s[i] = 3
    f(i + 1) f c = map(int, input().split()) map(int, input().split()) c
def f(i):
    global ans
    if i == n:
        w, x, y, z = 0, 0, 0, 0
        for i in range(n):
            if s[i] == 1:
                x += l[i]
            elif s[i] == 2:
                y += l[i]
            elif s[i] == 3:
                z += l[i]
            else:
                w += 1
        if x > 0 and y > 0 and z > 0:
            mp = abs(a - x) + abs(b - y) + abs(c - z) + 10 * (n - w - 3)
            ans = min(ans, mp)
        return
    s[i] = 0
    f(i + 1)
    s[i] = 1
    f(i + 1)
    s[i] = 2
    f(i + 1)
    s[i] = 3
    f(i + 1)

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
s = [3] * n
ans = 114514
f(0)
print(ans)