from sys import stdin
from itertools import product


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N,A,B,C = list(map(int,_in[0].split(' ')))  # type:list(int)
    l_arr = []
    for i in range(N):
        _ = int(_in[i+1])  # type:int
        l_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = float('inf')
    cand_arr = list(product([0,1,2,3],repeat=N))
    for cand in cand_arr:
        length = [0,0,0,0]
        if (1 in cand) and (2 in cand) and (3 in cand):
            for i,_len in zip(cand,l_arr):
                length[i] += _len
            _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3)
            cnt = min(cnt,_cnt)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt) from sys import stdin from itertools import product if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N,A,B,C = list(map(int,_in[0].split(' ')))  # type:list(int)
    l_arr = []
    for i in range(N):
        _ = int(_in[i+1])  # type:int
        l_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = float('inf')
    cand_arr = list(product([0,1,2,3],repeat=N))
    for cand in cand_arr:
        length = [0,0,0,0]
        if (1 in cand) and (2 in cand) and (3 in cand):
            for i,_len in zip(cand,l_arr):
                length[i] += _len
            _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3)
            cnt = min(cnt,_cnt)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt) __name__ == "__main__" __name__ "__main__" _.rstrip() for _ in stdin.readlines() for _ in stdin.readlines() _ stdin.readlines() stdin.readlines stdin readlines for _ in stdin.readlines() _.rstrip() _.rstrip _ rstrip _in = [_.rstrip() for _ in stdin.readlines()] _in [_.rstrip() for _ in stdin.readlines()] N,A,B,C = list(map(int,_in[0].split(' '))) N list(map(int,_in[0].split(' '))) list map(int,_in[0].split(' ')) map int _in[0].split(' ') [0].split [0] _in 0 split ' ' A B C l_arr = [] l_arr [] for i in range(N):
        _ = int(_in[i+1])  # type:int
        l_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
     i range(N) range N _ = int(_in[i+1]) _ int(_in[i+1]) int _in[i+1] _in i+1 i 1 l_arr.append(_) l_arr.append l_arr append _ cnt = float('inf') cnt float('inf') float 'inf' cand_arr = list(product([0,1,2,3],repeat=N)) cand_arr list(product([0,1,2,3],repeat=N)) list product([0,1,2,3],repeat=N) product [0,1,2,3] 0 1 2 3 repeat=N repeat N for cand in cand_arr:
        length = [0,0,0,0]
        if (1 in cand) and (2 in cand) and (3 in cand):
            for i,_len in zip(cand,l_arr):
                length[i] += _len
            _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3)
            cnt = min(cnt,_cnt)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     cand cand_arr length = [0,0,0,0] length [0,0,0,0] 0 0 0 0 if (1 in cand) and (2 in cand) and (3 in cand):
            for i,_len in zip(cand,l_arr):
                length[i] += _len
            _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3)
            cnt = min(cnt,_cnt)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     (1 in cand) and (2 in cand) and (3 in cand) (1 in cand) and (2 in cand) 1 in cand 1 cand 2 in cand 2 cand 3 in cand 3 cand for i,_len in zip(cand,l_arr):
                length[i] += _len
             i _len zip(cand,l_arr) zip cand l_arr length[i] += _len length[i] length i _len _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3) _cnt abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3) abs(A-length[1])+abs(B-length[2])+abs(C-length[3]) abs(A-length[1])+abs(B-length[2]) abs(A-length[1]) abs A-length[1] A length[1] length 1 abs(B-length[2]) abs B-length[2] B length[2] length 2 abs(C-length[3]) abs C-length[3] C length[3] length 3 10*(N-cand.count(0)-3) 10 N-cand.count(0)-3 N-cand.count(0) N cand.count(0) cand.count cand count 0 3 cnt = min(cnt,_cnt) cnt min(cnt,_cnt) min cnt _cnt print(cnt) print cnt N,A,B,C = list(map(int,_in[0].split(' '))) list(map(int,_in[0].split(' '))) N length = [0,0,0,0] [0,0,0,0] length A,B,C = list(map(int,_in[0].split(' '))) list(map(int,_in[0].split(' '))) A C = list(map(int,_in[0].split(' '))) list(map(int,_in[0].split(' '))) C _in = [_.rstrip() for _ in stdin.readlines()] [_.rstrip() for _ in stdin.readlines()] _in _ = int(_in[i+1]) int(_in[i+1]) _ cnt = min(cnt,_cnt) min(cnt,_cnt) cnt _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3) abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3) _cnt cnt = float('inf') float('inf') cnt cand_arr = list(product([0,1,2,3],repeat=N)) list(product([0,1,2,3],repeat=N)) cand_arr B,C = list(map(int,_in[0].split(' '))) list(map(int,_in[0].split(' '))) B l_arr = [] [] l_arr
from sys import stdin
from itertools import product


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N,A,B,C = list(map(int,_in[0].split(' ')))  # type:list(int)
    l_arr = []
    for i in range(N):
        _ = int(_in[i+1])  # type:int
        l_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = float('inf')
    cand_arr = list(product([0,1,2,3],repeat=N))
    for cand in cand_arr:
        length = [0,0,0,0]
        if (1 in cand) and (2 in cand) and (3 in cand):
            for i,_len in zip(cand,l_arr):
                length[i] += _len
            _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3)
            cnt = min(cnt,_cnt)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
