import sys
input = sys.stdin.buffer.readline

n,A,B,C = map(int,input().split())
L = []
for _ in range(n):
    L.append(int(input()))

res = 10**9

for i in range(4**n):
    flag = i
    a,b,c,tmp = 0,0,0,0
    for j in range(n):
        flag,now = divmod(flag,4)
        if now == 1:
            if a != 0:
                tmp += 10
            a += L[j]
        elif now == 2:
            if b != 0:
                tmp += 10
            b += L[j]
        elif now == 3:
            if c != 0:
                tmp += 10
            c += L[j]
    if a*b*c == 0:
        continue

    tmp += abs(A-a) + abs(B-b) + abs(C-c)

    res = min(res,tmp)

print(res) import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline n,A,B,C = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split A B C L = [] L [] for _ in range(n):
    L.append(int(input())) _ range(n) range n L.append(int(input())) L.append L append int(input()) int input() input res = 10**9 res 10**9 10 9 for i in range(4**n):
    flag = i
    a,b,c,tmp = 0,0,0,0
    for j in range(n):
        flag,now = divmod(flag,4)
        if now == 1:
            if a != 0:
                tmp += 10
            a += L[j]
        elif now == 2:
            if b != 0:
                tmp += 10
            b += L[j]
        elif now == 3:
            if c != 0:
                tmp += 10
            c += L[j]
    if a*b*c == 0:
        continue

    tmp += abs(A-a) + abs(B-b) + abs(C-c)

    res = min(res,tmp) i range(4**n) range 4**n 4 n flag = i flag i a,b,c,tmp = 0,0,0,0 a 0 b 0 c 0 tmp 0 for j in range(n):
        flag,now = divmod(flag,4)
        if now == 1:
            if a != 0:
                tmp += 10
            a += L[j]
        elif now == 2:
            if b != 0:
                tmp += 10
            b += L[j]
        elif now == 3:
            if c != 0:
                tmp += 10
            c += L[j]
     j range(n) range n flag,now = divmod(flag,4) flag divmod(flag,4) divmod flag 4 now if now == 1:
            if a != 0:
                tmp += 10
            a += L[j]
        elif now == 2:
            if b != 0:
                tmp += 10
            b += L[j]
        elif now == 3:
            if c != 0:
                tmp += 10
            c += L[j]
     now == 1 now 1 if a != 0:
                tmp += 10
             a != 0 a 0 tmp += 10 tmp 10 a += L[j] a L[j] L j elif now == 2:
            if b != 0:
                tmp += 10
            b += L[j]
         now == 2 now 2 if b != 0:
                tmp += 10
             b != 0 b 0 tmp += 10 tmp 10 b += L[j] b L[j] L j elif now == 3:
            if c != 0:
                tmp += 10
            c += L[j]
     now == 3 now 3 if c != 0:
                tmp += 10
             c != 0 c 0 tmp += 10 tmp 10 c += L[j] c L[j] L j if a*b*c == 0:
        continue

     a*b*c == 0 a*b*c a*b a b c 0 continue tmp += abs(A-a) + abs(B-b) + abs(C-c) tmp 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 res = min(res,tmp) res min(res,tmp) min res tmp print(res) print res flag,now = divmod(flag,4) divmod(flag,4) flag c,tmp = 0,0,0,0 0 c b += L[j] L[j] b L = [] [] L tmp += abs(A-a) + abs(B-b) + abs(C-c) abs(A-a) + abs(B-b) + abs(C-c) tmp res = min(res,tmp) min(res,tmp) res input = sys.stdin.buffer.readline sys.stdin.buffer.readline input b,c,tmp = 0,0,0,0 0 b C = map(int,input().split()) map(int,input().split()) C A,B,C = map(int,input().split()) map(int,input().split()) A B,C = map(int,input().split()) map(int,input().split()) B a += L[j] L[j] a c += L[j] L[j] c n,A,B,C = map(int,input().split()) map(int,input().split()) n tmp += 10 10 tmp now = divmod(flag,4) divmod(flag,4) now a,b,c,tmp = 0,0,0,0 0 a tmp += 10 10 tmp tmp = 0,0,0,0 0 tmp tmp += 10 10 tmp res = 10**9 10**9 res flag = i i flag
import sys
input = sys.stdin.buffer.readline

n,A,B,C = map(int,input().split())
L = []
for _ in range(n):
    L.append(int(input()))

res = 10**9

for i in range(4**n):
    flag = i
    a,b,c,tmp = 0,0,0,0
    for j in range(n):
        flag,now = divmod(flag,4)
        if now == 1:
            if a != 0:
                tmp += 10
            a += L[j]
        elif now == 2:
            if b != 0:
                tmp += 10
            b += L[j]
        elif now == 3:
            if c != 0:
                tmp += 10
            c += L[j]
    if a*b*c == 0:
        continue

    tmp += abs(A-a) + abs(B-b) + abs(C-c)

    res = min(res,tmp)

print(res)