n,A,B,C=map(int,input().split())
Q=[int(input()) for ii in range(n)]
inf=10**15
def dfs(now,a,b,c):
    if now==n:
        return abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf
    q1= dfs(now+1,a,b,c)
    q2= dfs(now+1, a+Q[now],b,c)+10
    q3= dfs(now+1, a, b+Q[now], c)+10
    q4 = dfs(now+1,a,b,c+Q[now])+10
    return min(q1,q2,q3,q4)

print(dfs(0,0,0,0)-30) 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 ii in range(n) for ii in range(n) ii range(n) range n for ii in range(n) int(input()) int input() input Q=[int(input()) for ii in range(n)] Q [int(input()) for ii in range(n)] inf=10**15 inf 10**15 10 15 def dfs(now,a,b,c):
    if now==n:
        return abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf
    q1= dfs(now+1,a,b,c)
    q2= dfs(now+1, a+Q[now],b,c)+10
    q3= dfs(now+1, a, b+Q[now], c)+10
    q4 = dfs(now+1,a,b,c+Q[now])+10
    return min(q1,q2,q3,q4) dfs if now==n:
        return abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf
     now==n now n return abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf 0 not in [a,b,c] 0 [a,b,c] a b c 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 inf q1= dfs(now+1,a,b,c) q1 dfs(now+1,a,b,c) dfs now+1 now 1 a b c q2= dfs(now+1, a+Q[now],b,c)+10 q2 dfs(now+1, a+Q[now],b,c)+10 dfs(now+1, a+Q[now],b,c) dfs now+1 now 1 a+Q[now] a Q[now] Q now b c 10 q3= dfs(now+1, a, b+Q[now], c)+10 q3 dfs(now+1, a, b+Q[now], c)+10 dfs(now+1, a, b+Q[now], c) dfs now+1 now 1 a b+Q[now] b Q[now] Q now c 10 q4 = dfs(now+1,a,b,c+Q[now])+10 q4 dfs(now+1,a,b,c+Q[now])+10 dfs(now+1,a,b,c+Q[now]) dfs now+1 now 1 a b c+Q[now] c Q[now] Q now 10 return min(q1,q2,q3,q4) min(q1,q2,q3,q4) min q1 q2 q3 q4 now now a a b b c c print(dfs(0,0,0,0)-30) print dfs(0,0,0,0)-30 dfs(0,0,0,0) dfs 0 0 0 0 30 Q=[int(input()) for ii in range(n)] [int(input()) for ii in range(n)] Q inf=10**15 10**15 inf C=map(int,input().split()) map(int,input().split()) C 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 B,C=map(int,input().split()) map(int,input().split()) B def dfs(now,a,b,c):
    if now==n:
        return abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf
    q1= dfs(now+1,a,b,c)
    q2= dfs(now+1, a+Q[now],b,c)+10
    q3= dfs(now+1, a, b+Q[now], c)+10
    q4 = dfs(now+1,a,b,c+Q[now])+10
    return min(q1,q2,q3,q4) def dfs(now,a,b,c):
    if now==n:
        return abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf
    q1= dfs(now+1,a,b,c)
    q2= dfs(now+1, a+Q[now],b,c)+10
    q3= dfs(now+1, a, b+Q[now], c)+10
    q4 = dfs(now+1,a,b,c+Q[now])+10
    return min(q1,q2,q3,q4) dfs
n,A,B,C=map(int,input().split())
Q=[int(input()) for ii in range(n)]
inf=10**15
def dfs(now,a,b,c):
    if now==n:
        return abs(a-A)+abs(b-B)+abs(c-C) if 0 not in [a,b,c] else inf
    q1= dfs(now+1,a,b,c)
    q2= dfs(now+1, a+Q[now],b,c)+10
    q3= dfs(now+1, a, b+Q[now], c)+10
    q4 = dfs(now+1,a,b,c+Q[now])+10
    return min(q1,q2,q3,q4)

print(dfs(0,0,0,0)-30)