N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]
ans = float('inf')
for i in range(2**N):
    da = [True]*N
    for j in range(N):
        if (i>>j) & 1:
            da[j] = False
    a = []
    lb = []
    for j in range(N):
        if da[j] == True:
            a.append(l[j])
        else:
            lb.append(l[j])
    #print(a,lb)
    if len(lb) >= 2:
        for j in range(2**len(lb)):
            db = [True] * len(lb)
            for k in range(len(lb)):
                if (j>>k) & 1:
                    db[k] = False
            b = []
            lc = []
            for k in range(len(lb)):
                if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
            if len(lc) >= 1:
                for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          )
print(ans)


     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)] ans = float('inf') ans float('inf') float 'inf' for i in range(2**N):
    da = [True]*N
    for j in range(N):
        if (i>>j) & 1:
            da[j] = False
    a = []
    lb = []
    for j in range(N):
        if da[j] == True:
            a.append(l[j])
        else:
            lb.append(l[j])
    #print(a,lb)
    if len(lb) >= 2:
        for j in range(2**len(lb)):
            db = [True] * len(lb)
            for k in range(len(lb)):
                if (j>>k) & 1:
                    db[k] = False
            b = []
            lc = []
            for k in range(len(lb)):
                if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
            if len(lc) >= 1:
                for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) i range(2**N) range 2**N 2 N da = [True]*N da [True]*N [True] True N for j in range(N):
        if (i>>j) & 1:
            da[j] = False
     j range(N) range N if (i>>j) & 1:
            da[j] = False
     (i>>j) & 1 i>>j i j 1 da[j] = False da[j] da j False a = [] a [] lb = [] lb [] for j in range(N):
        if da[j] == True:
            a.append(l[j])
        else:
            lb.append(l[j])
    #print(a,lb)
     j range(N) range N if da[j] == True:
            a.append(l[j])
        else:
            lb.append(l[j])
    #print(a,lb)
     da[j] == True da[j] da j True a.append(l[j]) a.append a append l[j] l j lb.append(l[j]) lb.append lb append l[j] l j if len(lb) >= 2:
        for j in range(2**len(lb)):
            db = [True] * len(lb)
            for k in range(len(lb)):
                if (j>>k) & 1:
                    db[k] = False
            b = []
            lc = []
            for k in range(len(lb)):
                if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
            if len(lc) >= 1:
                for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) len(lb) >= 2 len(lb) len lb 2 for j in range(2**len(lb)):
            db = [True] * len(lb)
            for k in range(len(lb)):
                if (j>>k) & 1:
                    db[k] = False
            b = []
            lc = []
            for k in range(len(lb)):
                if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
            if len(lc) >= 1:
                for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) j range(2**len(lb)) range 2**len(lb) 2 len(lb) len lb db = [True] * len(lb) db [True] * len(lb) [True] True len(lb) len lb for k in range(len(lb)):
                if (j>>k) & 1:
                    db[k] = False
             k range(len(lb)) range len(lb) len lb if (j>>k) & 1:
                    db[k] = False
             (j>>k) & 1 j>>k j k 1 db[k] = False db[k] db k False b = [] b [] lc = [] lc [] for k in range(len(lb)):
                if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
             k range(len(lb)) range len(lb) len lb if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
             db[k] == True db[k] db k True b.append(lb[k]) b.append b append lb[k] lb k lc.append(lb[k]) lc.append lc append lb[k] lb k if len(lc) >= 1:
                for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) len(lc) >= 1 len(lc) len lc 1 for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) k range(2**len(lc)) range 2**len(lc) 2 len(lc) len lc dc = [True] * len(lc) dc [True] * len(lc) [True] True len(lc) len lc for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                     m range(len(lc)) range len(lc) len lc if (k>>m) & 1:
                            dc[m] = False
                     (k>>m) & 1 k>>m k m 1 dc[m] = False dc[m] dc m False c = [] c [] for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                     m range(len(lc)) range len(lc) len lc if dc[m] == True:
                            c.append(lc[m])
                     dc[m] == True dc[m] dc m True c.append(lc[m]) c.append c append lc[m] lc m if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) len(a) > 0 and len(b) > 0 and len(c) > 0 len(a) > 0 and len(b) > 0 len(a) > 0 len(a) len a 0 len(b) > 0 len(b) len b 0 len(c) > 0 len(c) len c 0 ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) ans min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) min ans 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c)) 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1) 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1) 10*(len(a)-1)+abs(A-sum(a)) 10*(len(a)-1) 10 len(a)-1 len(a) len a 1 abs(A-sum(a)) abs A-sum(a) A sum(a) sum a 10*(len(b)-1) 10 len(b)-1 len(b) len b 1 abs(B-sum(b)) abs B-sum(b) B sum(b) sum b 10*(len(c)-1) 10 len(c)-1 len(c) len c 1 abs(C-sum(c)) abs C-sum(c) C sum(c) sum c print(ans) print ans l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l B,C = map(int,input().split()) map(int,input().split()) B b = [] [] b dc = [True] * len(lc) [True] * len(lc) dc a = [] [] a ans = float('inf') float('inf') ans ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          ) ans lb = [] [] lb db = [True] * len(lb) [True] * len(lb) db C = map(int,input().split()) map(int,input().split()) C da = [True]*N [True]*N da N,A,B,C = map(int,input().split()) map(int,input().split()) N A,B,C = map(int,input().split()) map(int,input().split()) A lc = [] [] lc c = [] [] c
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]
ans = float('inf')
for i in range(2**N):
    da = [True]*N
    for j in range(N):
        if (i>>j) & 1:
            da[j] = False
    a = []
    lb = []
    for j in range(N):
        if da[j] == True:
            a.append(l[j])
        else:
            lb.append(l[j])
    #print(a,lb)
    if len(lb) >= 2:
        for j in range(2**len(lb)):
            db = [True] * len(lb)
            for k in range(len(lb)):
                if (j>>k) & 1:
                    db[k] = False
            b = []
            lc = []
            for k in range(len(lb)):
                if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
            if len(lc) >= 1:
                for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          )
print(ans)


    
