import sys
sys.setrecursionlimit(10**6)
n, A, B, C =map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
inf=10**9
"""
解法
それぞれの竹について「Aの材料」、「Bの材料」、「Cの材料」、「使わない」の4択を決める(4**n通り)
"""
def dfs(cur, a, b, c):
    if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0)) import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 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 inf=10**9 inf 10**9 10 9 """
解法
それぞれの竹について「Aの材料」、「Bの材料」、「Cの材料」、「使わない」の4択を決める(4**n通り)
""" def dfs(cur, a, b, c):
    if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0, ret1, ret2, ret3) dfs if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    
     cur==n cur n return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf min(a,b,c)>0 min(a,b,c) min a b c 0 abs(a-A)+abs(b-B)+abs(c-C)-30 abs(a-A)+abs(b-B)+abs(c-C) abs(a-A)+abs(b-B) abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C 30 inf ret0=dfs(cur+1,a,b,c) ret0 dfs(cur+1,a,b,c) dfs cur+1 cur 1 a b c ret1=dfs(cur+1,a+l[cur],b,c)+10 ret1 dfs(cur+1,a+l[cur],b,c)+10 dfs(cur+1,a+l[cur],b,c) dfs cur+1 cur 1 a+l[cur] a l[cur] l cur b c 10 ret2=dfs(cur+1,a,b+l[cur],c)+10 ret2 dfs(cur+1,a,b+l[cur],c)+10 dfs(cur+1,a,b+l[cur],c) dfs cur+1 cur 1 a b+l[cur] b l[cur] l cur c 10 ret3=dfs(cur+1,a,b,c+l[cur])+10 ret3 dfs(cur+1,a,b,c+l[cur])+10 dfs(cur+1,a,b,c+l[cur]) dfs cur+1 cur 1 a b c+l[cur] c l[cur] l cur 10 return min(ret0, ret1, ret2, ret3) min(ret0, ret1, ret2, ret3) min ret0 ret1 ret2 ret3 cur cur a a b b c c print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 C =map(int,input().split()) map(int,input().split()) C inf=10**9 10**9 inf l=[] [] l def dfs(cur, a, b, c):
    if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0, ret1, ret2, ret3) def dfs(cur, a, b, c):
    if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0, ret1, ret2, ret3) dfs B, C =map(int,input().split()) map(int,input().split()) B 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
import sys
sys.setrecursionlimit(10**6)
n, A, B, C =map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
inf=10**9
"""
解法
それぞれの竹について「Aの材料」、「Bの材料」、「Cの材料」、「使わない」の4択を決める(4**n通り)
"""
def dfs(cur, a, b, c):
    if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0, ret1, ret2, ret3)

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