# ＤＦＳ, パターン列挙_竹'n'本の使用パターン
'''
from collections import deque

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

queue = deque([[0],[1],[2],[-1]]) # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
 
while queue: # stackが空になるまでループ
    tmp = queue.pop() # パターンの候補を pop
    if len(tmp) == n: # 条件に合えば append
        ptns.append(tmp)
    elif len(tmp) < n: # 条件に合わなければ...
        w = tmp + [0] # パターンの候補を作成して...
        x = tmp + [1] # 〃
        y = tmp + [2] # 〃
        z = tmp + [-1]
        queue += [w, x, y, z]  # 積む

#print(ptns) # 竹の使用パターン

ans = 10**9
for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp)

print(ans)

'''
# パターン列挙と探索を並行して処理

from collections import deque

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

queue = deque([[0],[1],[2],[-1]])

ans = 10**9
while queue:
    tmp = queue.pop()
    if len(tmp) == n:
        if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
        abc = [0, 0, 0, -30]
        for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
        mp = abc[3]
        mp += abs(abc[0] - a)
        mp += abs(abc[1] - b)
        mp += abs(abc[2] - c)
        ans = min(ans, mp)

    elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        queue += [w, x, y, z]

print(ans) '''
from collections import deque

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

queue = deque([[0],[1],[2],[-1]]) # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
 
while queue: # stackが空になるまでループ
    tmp = queue.pop() # パターンの候補を pop
    if len(tmp) == n: # 条件に合えば append
        ptns.append(tmp)
    elif len(tmp) < n: # 条件に合わなければ...
        w = tmp + [0] # パターンの候補を作成して...
        x = tmp + [1] # 〃
        y = tmp + [2] # 〃
        z = tmp + [-1]
        queue += [w, x, y, z]  # 積む

#print(ptns) # 竹の使用パターン

ans = 10**9
for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp)

print(ans)

''' from collections import deque 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)] queue = deque([[0],[1],[2],[-1]]) queue deque([[0],[1],[2],[-1]]) deque [[0],[1],[2],[-1]] [0] 0 [1] 1 [2] 2 [-1] -1 ans = 10**9 ans 10**9 10 9 while queue:
    tmp = queue.pop()
    if len(tmp) == n:
        if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
        abc = [0, 0, 0, -30]
        for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
        mp = abc[3]
        mp += abs(abc[0] - a)
        mp += abs(abc[1] - b)
        mp += abs(abc[2] - c)
        ans = min(ans, mp)

    elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        queue += [w, x, y, z] queue tmp = queue.pop() tmp queue.pop() queue.pop queue pop if len(tmp) == n:
        if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
        abc = [0, 0, 0, -30]
        for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
        mp = abc[3]
        mp += abs(abc[0] - a)
        mp += abs(abc[1] - b)
        mp += abs(abc[2] - c)
        ans = min(ans, mp)

    elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        queue += [w, x, y, z] len(tmp) == n len(tmp) len tmp n if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
         0 not in tmp or 1 not in tmp or 2 not in tmp 0 not in tmp or 1 not in tmp 0 not in tmp 0 tmp 1 not in tmp 1 tmp 2 not in tmp 2 tmp continue abc = [0, 0, 0, -30] abc [0, 0, 0, -30] 0 0 0 -30 for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
         j range(n) range n if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
         tmp[j] >= 0 tmp[j] tmp j 0 abc[tmp[j]] += l[j] abc[tmp[j]] abc tmp[j] tmp j l[j] l j abc[3] += 10 abc[3] abc 3 10 mp = abc[3] mp abc[3] abc 3 mp += abs(abc[0] - a) mp abs(abc[0] - a) abs abc[0] - a abc[0] abc 0 a mp += abs(abc[1] - b) mp abs(abc[1] - b) abs abc[1] - b abc[1] abc 1 b mp += abs(abc[2] - c) mp abs(abc[2] - c) abs abc[2] - c abc[2] abc 2 c ans = min(ans, mp) ans min(ans, mp) min ans mp elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        queue += [w, x, y, z] len(tmp) < n len(tmp) len tmp n w = tmp + [0] w tmp + [0] tmp [0] 0 x = tmp + [1] x tmp + [1] tmp [1] 1 y = tmp + [2] y tmp + [2] tmp [2] 2 z = tmp + [-1] z tmp + [-1] tmp [-1] -1 queue += [w, x, y, z] queue [w, x, y, z] w x y z print(ans) print ans mp += abs(abc[0] - a) abs(abc[0] - a) mp ans = 10**9 10**9 ans b, c = map(int, input().split()) map(int, input().split()) b c = map(int, input().split()) map(int, input().split()) c tmp = queue.pop() queue.pop() tmp n, a, b, c = map(int, input().split()) map(int, input().split()) n mp = abc[3] abc[3] mp w = tmp + [0] tmp + [0] w l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l mp += abs(abc[2] - c) abs(abc[2] - c) mp queue = deque([[0],[1],[2],[-1]]) deque([[0],[1],[2],[-1]]) queue ans = min(ans, mp) min(ans, mp) ans queue += [w, x, y, z] [w, x, y, z] queue z = tmp + [-1] tmp + [-1] z x = tmp + [1] tmp + [1] x a, b, c = map(int, input().split()) map(int, input().split()) a y = tmp + [2] tmp + [2] y abc = [0, 0, 0, -30] [0, 0, 0, -30] abc mp += abs(abc[1] - b) abs(abc[1] - b) mp
# ＤＦＳ, パターン列挙_竹'n'本の使用パターン
'''
from collections import deque

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

queue = deque([[0],[1],[2],[-1]]) # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
 
while queue: # stackが空になるまでループ
    tmp = queue.pop() # パターンの候補を pop
    if len(tmp) == n: # 条件に合えば append
        ptns.append(tmp)
    elif len(tmp) < n: # 条件に合わなければ...
        w = tmp + [0] # パターンの候補を作成して...
        x = tmp + [1] # 〃
        y = tmp + [2] # 〃
        z = tmp + [-1]
        queue += [w, x, y, z]  # 積む

#print(ptns) # 竹の使用パターン

ans = 10**9
for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp)

print(ans)

'''
# パターン列挙と探索を並行して処理

from collections import deque

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

queue = deque([[0],[1],[2],[-1]])

ans = 10**9
while queue:
    tmp = queue.pop()
    if len(tmp) == n:
        if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
        abc = [0, 0, 0, -30]
        for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
        mp = abc[3]
        mp += abs(abc[0] - a)
        mp += abs(abc[1] - b)
        mp += abs(abc[2] - c)
        ans = min(ans, mp)

    elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        queue += [w, x, y, z]

print(ans)
