n, a, b, c = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))
ans = 10**9    
for ci in range(4**n):
    ci_ = [-1] * n
    cnt = [0] * 3
    ca, cb, cc = 0, 0, 0
    for cj in range(n):
        cx = ci & 3
        if cx == 0:
            ca += l[cj]
            cnt[0] += 1 
        elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
        elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
        ci >>= 2
    if ca == 0 or cb == 0 or cc == 0:
        continue
    
    cost = 0
    for i in range(3):
        if cnt[i] > 1:
            cost += 10 * (cnt[i]-1)
    cost += abs(a-ca) + abs(b-cb) + abs(c-cc)
    ans = min(ans, cost)
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 l = [] l [] for i in range(n):
    l.append(int(input())) i range(n) range n l.append(int(input())) l.append l append int(input()) int input() input ans = 10**9 ans 10**9 10 9 for ci in range(4**n):
    ci_ = [-1] * n
    cnt = [0] * 3
    ca, cb, cc = 0, 0, 0
    for cj in range(n):
        cx = ci & 3
        if cx == 0:
            ca += l[cj]
            cnt[0] += 1 
        elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
        elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
        ci >>= 2
    if ca == 0 or cb == 0 or cc == 0:
        continue
    
    cost = 0
    for i in range(3):
        if cnt[i] > 1:
            cost += 10 * (cnt[i]-1)
    cost += abs(a-ca) + abs(b-cb) + abs(c-cc)
    ans = min(ans, cost) ci range(4**n) range 4**n 4 n ci_ = [-1] * n ci_ [-1] * n [-1] -1 n cnt = [0] * 3 cnt [0] * 3 [0] 0 3 ca, cb, cc = 0, 0, 0 ca 0 cb 0 cc 0 for cj in range(n):
        cx = ci & 3
        if cx == 0:
            ca += l[cj]
            cnt[0] += 1 
        elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
        elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
        ci >>= 2
     cj range(n) range n cx = ci & 3 cx ci & 3 ci 3 if cx == 0:
            ca += l[cj]
            cnt[0] += 1 
        elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
        elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
         cx == 0 cx 0 ca += l[cj] ca l[cj] l cj cnt[0] += 1 cnt[0] cnt 0 1 elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
         cx == 1 cx 1 cb += l[cj] cb l[cj] l cj cnt[1] += 1 cnt[1] cnt 1 1 elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
         cx == 2 cx 2 cc += l[cj] cc l[cj] l cj cnt[2] += 1 cnt[2] cnt 2 1 ci >>= 2 ci 2 if ca == 0 or cb == 0 or cc == 0:
        continue
    
     ca == 0 or cb == 0 or cc == 0 ca == 0 or cb == 0 ca == 0 ca 0 cb == 0 cb 0 cc == 0 cc 0 continue cost = 0 cost 0 for i in range(3):
        if cnt[i] > 1:
            cost += 10 * (cnt[i]-1)
     i range(3) range 3 if cnt[i] > 1:
            cost += 10 * (cnt[i]-1)
     cnt[i] > 1 cnt[i] cnt i 1 cost += 10 * (cnt[i]-1) cost 10 * (cnt[i]-1) 10 cnt[i]-1 cnt[i] cnt i 1 cost += abs(a-ca) + abs(b-cb) + abs(c-cc) cost abs(a-ca) + abs(b-cb) + abs(c-cc) abs(a-ca) + abs(b-cb) abs(a-ca) abs a-ca a ca abs(b-cb) abs b-cb b cb abs(c-cc) abs c-cc c cc ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans ci_ = [-1] * n [-1] * n ci_ cost = 0 0 cost n, a, b, c = map(int,input().split()) map(int,input().split()) n l = [] [] l ca, cb, cc = 0, 0, 0 0 ca cost += 10 * (cnt[i]-1) 10 * (cnt[i]-1) cost ans = 10**9 10**9 ans ans = min(ans, cost) min(ans, cost) ans cc += l[cj] l[cj] cc c = map(int,input().split()) map(int,input().split()) c cb += l[cj] l[cj] cb cost += abs(a-ca) + abs(b-cb) + abs(c-cc) abs(a-ca) + abs(b-cb) + abs(c-cc) cost cb, cc = 0, 0, 0 0 cb ca += l[cj] l[cj] ca b, c = map(int,input().split()) map(int,input().split()) b a, b, c = map(int,input().split()) map(int,input().split()) a cnt = [0] * 3 [0] * 3 cnt cc = 0, 0, 0 0 cc ci >>= 2 2 ci cx = ci & 3 ci & 3 cx
n, a, b, c = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))
ans = 10**9    
for ci in range(4**n):
    ci_ = [-1] * n
    cnt = [0] * 3
    ca, cb, cc = 0, 0, 0
    for cj in range(n):
        cx = ci & 3
        if cx == 0:
            ca += l[cj]
            cnt[0] += 1 
        elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
        elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
        ci >>= 2
    if ca == 0 or cb == 0 or cc == 0:
        continue
    
    cost = 0
    for i in range(3):
        if cnt[i] > 1:
            cost += 10 * (cnt[i]-1)
    cost += abs(a-ca) + abs(b-cb) + abs(c-cc)
    ans = min(ans, cost)
print(ans)