def B10N(X,B):
    if X//B!=0: return B10N(X//B,B)+str(X%B)
    return str(X%B)

N,A,B,C = (int(X) for X in input().split())
Li = [int(input()) for X in range(0,N)]
CostM = pow(10,9)
for T in range(0,pow(4,N)):
    Cho = list(B10N(T,4).zfill(N))
    if Cho.count('1')>0 and Cho.count('2')>0 and Cho.count('3')>0:
        Cost = 0
        ALi = [Li[X] for X,Y in enumerate(Cho) if Y=='1']
        BLi = [Li[X] for X,Y in enumerate(Cho) if Y=='2']
        CLi = [Li[X] for X,Y in enumerate(Cho) if Y=='3']
        SyC = (len(ALi)+len(BLi)+len(CLi)-3)*10
        LeC = abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C)
        if SyC+LeC<CostM: CostM = SyC+LeC
print(CostM) def B10N(X,B):
    if X//B!=0: return B10N(X//B,B)+str(X%B)
    return str(X%B) B10N if X//B!=0: return B10N(X//B,B)+str(X%B)
     X//B!=0 X//B X B 0 return str(X%B) str(X%B) str X%B X B X X B B int(X) for X in input().split() for X in input().split() X input().split() ().split () input split for X in input().split() int(X) int X N,A,B,C = (int(X) for X in input().split()) N (int(X) for X in input().split()) A B C int(input()) for X in range(0,N) for X in range(0,N) X range(0,N) range 0 N for X in range(0,N) int(input()) int input() input Li = [int(input()) for X in range(0,N)] Li [int(input()) for X in range(0,N)] CostM = pow(10,9) CostM pow(10,9) pow 10 9 for T in range(0,pow(4,N)):
    Cho = list(B10N(T,4).zfill(N))
    if Cho.count('1')>0 and Cho.count('2')>0 and Cho.count('3')>0:
        Cost = 0
        ALi = [Li[X] for X,Y in enumerate(Cho) if Y=='1']
        BLi = [Li[X] for X,Y in enumerate(Cho) if Y=='2']
        CLi = [Li[X] for X,Y in enumerate(Cho) if Y=='3']
        SyC = (len(ALi)+len(BLi)+len(CLi)-3)*10
        LeC = abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C)
        if SyC+LeC<CostM: CostM = SyC+LeC T range(0,pow(4,N)) range 0 pow(4,N) pow 4 N Cho = list(B10N(T,4).zfill(N)) Cho list(B10N(T,4).zfill(N)) list B10N(T,4).zfill(N) (T,4).zfill (T,4) B10N T 4 zfill N if Cho.count('1')>0 and Cho.count('2')>0 and Cho.count('3')>0:
        Cost = 0
        ALi = [Li[X] for X,Y in enumerate(Cho) if Y=='1']
        BLi = [Li[X] for X,Y in enumerate(Cho) if Y=='2']
        CLi = [Li[X] for X,Y in enumerate(Cho) if Y=='3']
        SyC = (len(ALi)+len(BLi)+len(CLi)-3)*10
        LeC = abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C)
        if SyC+LeC<CostM: CostM = SyC+LeC Cho.count('1')>0 and Cho.count('2')>0 and Cho.count('3')>0 Cho.count('1')>0 and Cho.count('2')>0 Cho.count('1')>0 Cho.count('1') Cho.count Cho count '1' 0 Cho.count('2')>0 Cho.count('2') Cho.count Cho count '2' 0 Cho.count('3')>0 Cho.count('3') Cho.count Cho count '3' 0 Cost = 0 Cost 0 Li[X] for X,Y in enumerate(Cho) if Y=='1' for X,Y in enumerate(Cho) if Y=='1' X Y enumerate(Cho) enumerate Cho Y=='1' Y '1' if Y=='1' Li[X] Li X ALi = [Li[X] for X,Y in enumerate(Cho) if Y=='1'] ALi [Li[X] for X,Y in enumerate(Cho) if Y=='1'] Li[X] for X,Y in enumerate(Cho) if Y=='2' for X,Y in enumerate(Cho) if Y=='2' X Y enumerate(Cho) enumerate Cho Y=='2' Y '2' if Y=='2' Li[X] Li X BLi = [Li[X] for X,Y in enumerate(Cho) if Y=='2'] BLi [Li[X] for X,Y in enumerate(Cho) if Y=='2'] Li[X] for X,Y in enumerate(Cho) if Y=='3' for X,Y in enumerate(Cho) if Y=='3' X Y enumerate(Cho) enumerate Cho Y=='3' Y '3' if Y=='3' Li[X] Li X CLi = [Li[X] for X,Y in enumerate(Cho) if Y=='3'] CLi [Li[X] for X,Y in enumerate(Cho) if Y=='3'] SyC = (len(ALi)+len(BLi)+len(CLi)-3)*10 SyC (len(ALi)+len(BLi)+len(CLi)-3)*10 len(ALi)+len(BLi)+len(CLi)-3 len(ALi)+len(BLi)+len(CLi) len(ALi)+len(BLi) len(ALi) len ALi len(BLi) len BLi len(CLi) len CLi 3 10 LeC = abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C) LeC abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C) abs(sum(ALi)-A)+abs(sum(BLi)-B) abs(sum(ALi)-A) abs sum(ALi)-A sum(ALi) sum ALi A abs(sum(BLi)-B) abs sum(BLi)-B sum(BLi) sum BLi B abs(sum(CLi)-C) abs sum(CLi)-C sum(CLi) sum CLi C if SyC+LeC<CostM: CostM = SyC+LeC<CostM SyC+LeC SyC LeC CostM print(CostM) print CostM Li = [int(input()) for X in range(0,N)] [int(input()) for X in range(0,N)] Li B,C = (int(X) for X in input().split()) (int(X) for X in input().split()) B Cost = 0 0 Cost C = (int(X) for X in input().split()) (int(X) for X in input().split()) C CostM = pow(10,9) pow(10,9) CostM BLi = [Li[X] for X,Y in enumerate(Cho) if Y=='2'] [Li[X] for X,Y in enumerate(Cho) if Y=='2'] BLi Cho = list(B10N(T,4).zfill(N)) list(B10N(T,4).zfill(N)) Cho N,A,B,C = (int(X) for X in input().split()) (int(X) for X in input().split()) N def B10N(X,B):
    if X//B!=0: return B10N(X//B,B)+str(X%B)
    return str(X%B) def B10N(X,B):
    if X//B!=0: return B10N(X//B,B)+str(X%B)
    return str(X%B) B10N A,B,C = (int(X) for X in input().split()) (int(X) for X in input().split()) A ALi = [Li[X] for X,Y in enumerate(Cho) if Y=='1'] [Li[X] for X,Y in enumerate(Cho) if Y=='1'] ALi CLi = [Li[X] for X,Y in enumerate(Cho) if Y=='3'] [Li[X] for X,Y in enumerate(Cho) if Y=='3'] CLi SyC = (len(ALi)+len(BLi)+len(CLi)-3)*10 (len(ALi)+len(BLi)+len(CLi)-3)*10 SyC LeC = abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C) abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C) LeC
def B10N(X,B):
    if X//B!=0: return B10N(X//B,B)+str(X%B)
    return str(X%B)

N,A,B,C = (int(X) for X in input().split())
Li = [int(input()) for X in range(0,N)]
CostM = pow(10,9)
for T in range(0,pow(4,N)):
    Cho = list(B10N(T,4).zfill(N))
    if Cho.count('1')>0 and Cho.count('2')>0 and Cho.count('3')>0:
        Cost = 0
        ALi = [Li[X] for X,Y in enumerate(Cho) if Y=='1']
        BLi = [Li[X] for X,Y in enumerate(Cho) if Y=='2']
        CLi = [Li[X] for X,Y in enumerate(Cho) if Y=='3']
        SyC = (len(ALi)+len(BLi)+len(CLi)-3)*10
        LeC = abs(sum(ALi)-A)+abs(sum(BLi)-B)+abs(sum(CLi)-C)
        if SyC+LeC<CostM: CostM = SyC+LeC
print(CostM)