# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0

# abcde	s=input()	s='abcde'

# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 5(1つだけ)	a=int(input())	a=5

# 1 2	| x,y = map(int,input().split())   |	x=1,y=2

# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']

# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]

# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']



# INPUT

# 3

# hoge

# foo

# bar

# ANSWER

# n=int(input())

# string_list=[input() for i in range(n)]



import math

import numpy as np

import copy

from collections import defaultdict, Counter

from itertools import product

from bisect import bisect_left, bisect_right

def inpl(): return list(map(int, input().split()))



li = list(map(int, input().split()))

N, A, B, C = li[0], li[1], li[2], li[3]

l = sorted([ int(eval(input())) for i in range(N) ])



ans = 1e9



# 0~3のデカルト積

# 0~3の組み合わせ全部

for X in product(list(range(4)), repeat=N):

    # [[未使用], [Aの作成に使う], [Bの作成に使う], [Cの作成に使う]]

    # 作成の際使う竹は必ず合成する

    P = [[] for _ in range(4)]

    for i, x in enumerate(X):

        P[x].append(l[i])



    # A, B, Cを合成する竹がない場合スキップ

    if min(list(map(len, P[1:]))) == 0:

        continue



    tmp = 0

    for q, d in zip(P[1:], [A, B, C]):

        tmp += 10*(len(q)-1) + abs(d-sum(q))

    if tmp < ans:

        ans = min(tmp, ans)



print(ans)
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0

# abcde	s=input()	s='abcde'

# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 5(1つだけ)	a=int(input())	a=5

# 1 2	| x,y = map(int,input().split())   |	x=1,y=2

# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']

# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]

# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']



# INPUT

# 3

# hoge

# foo

# bar

# ANSWER

# n=int(input())

# string_list=[input() for i in range(n)]



import math

import numpy as np

import copy

from collections import defaultdict, Counter

from itertools import product

from bisect import bisect_left, bisect_right

def inpl(): return list(map(int, input().split()))



li = list(map(int, input().split()))

N, A, B, C = li[0], li[1], li[2], li[3]

l = sorted([ int(eval(input())) for i in range(N) ])



INF = 1e9



def dfs(ind, a, b, c):

    if ind == N:

        if min(a, b, c) > 0:

            return abs(a-A) + abs(b-B) + abs(c-C) - 30

        else:

            return INF

    ret0 = dfs(ind+1, a, b, c)

    ret1 = dfs(ind+1, a + l[ind], b, c) + 10

    ret2 = dfs(ind+1, a, b + l[ind], c) + 10

    ret3 = dfs(ind+1, a, b, c + l[ind]) + 10

    return min(ret0, ret1, ret2, ret3)



print((dfs(0, 0, 0, 0)))
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']
# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]
import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right


def inpl():
    return list(map(int, input().split()))


li = list(map(int, input().split()))
N, A, B, C = li[0], li[1], li[2], li[3]
l = sorted([int(eval(input())) for i in range(N)])
ans = 1e9
# 0~3のデカルト積
# 0~3の組み合わせ全部
for X in product(list(range(4)), repeat=N):
    # [[未使用], [Aの作成に使う], [Bの作成に使う], [Cの作成に使う]]
    # 作成の際使う竹は必ず合成する
    P = [[] for _ in range(4)]
    for i, x in enumerate(X):
        P[x].append(l[i])
    # A, B, Cを合成する竹がない場合スキップ
    if min(list(map(len, P[1:]))) == 0:
        continue
    tmp = 0
    for q, d in zip(P[1:], [A, B, C]):
        tmp += 10 * (len(q) - 1) + abs(d - sum(q))
    if tmp < ans:
        ans = min(tmp, ans)
print(ans)

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']
# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]
import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right


def inpl():
    return list(map(int, input().split()))


li = list(map(int, input().split()))
N, A, B, C = li[0], li[1], li[2], li[3]
l = sorted([int(eval(input())) for i in range(N)])
INF = 1e9


def dfs(ind, a, b, c):
    if ind == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF
    ret0 = dfs(ind + 1, a, b, c)
    ret1 = dfs(ind + 1, a + l[ind], b, c) + 10
    ret2 = dfs(ind + 1, a, b + l[ind], c) + 10
    ret3 = dfs(ind + 1, a, b, c + l[ind]) + 10
    return min(ret0, ret1, ret2, ret3)


print((dfs(0, 0, 0, 0)))

-ans = 1e9 -# 0~3のデカルト積 -# 0~3の組み合わせ全部 -for X in product(list(range(4)), repeat=N): -    # [[未使用], [Aの作成に使う], [Bの作成に使う], [Cの作成に使う]] -    # 作成の際使う竹は必ず合成する -    P = [[] for _ in range(4)] -    for i, x in enumerate(X): -        P[x].append(l[i]) -    # A, B, Cを合成する竹がない場合スキップ -    if min(list(map(len, P[1:]))) == 0: -        continue -    tmp = 0 -    for q, d in zip(P[1:], [A, B, C]): -        tmp += 10 * (len(q) - 1) + abs(d - sum(q)) -    if tmp < ans: -        ans = min(tmp, ans) -print(ans) +INF = 1e9 + + +def dfs(ind, a, b, c): +    if ind == N: +        if min(a, b, c) > 0: +            return abs(a - A) + abs(b - B) + abs(c - C) - 30 +        else: +            return INF +    ret0 = dfs(ind + 1, a, b, c) +    ret1 = dfs(ind + 1, a + l[ind], b, c) + 10 +    ret2 = dfs(ind + 1, a, b + l[ind], c) + 10 +    ret3 = dfs(ind + 1, a, b, c + l[ind]) + 10 +    return min(ret0, ret1, ret2, ret3) + + +print((dfs(0, 0, 0, 0)))