n,A,B,C=map(int,input().split())

l=[int(input()) for _ in range(n)]



def dfs(count,a,b,c):
    if count==n:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
    x = dfs(count+1, a, b, c)
    y = dfs(count+1, a+l[count], b, c)+10
    z = dfs(count+1, a, b+l[count], c)+10
    w = dfs(count+1, a, b, c+l[count])+10
    return min(x,y,z,w)



print(dfs(0,0,0,0)) 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)] def dfs(count,a,b,c):
    if count==n:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
    x = dfs(count+1, a, b, c)
    y = dfs(count+1, a+l[count], b, c)+10
    z = dfs(count+1, a, b+l[count], c)+10
    w = dfs(count+1, a, b, c+l[count])+10
    return min(x,y,z,w) dfs if count==n:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
     count==n count n if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
     min(a,b,c)>0 min(a,b,c) min a b c 0 return abs(a-A)+abs(b-B)+abs(c-C)-30 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 return 10**9+1 10**9+1 10**9 10 9 1 x = dfs(count+1, a, b, c) x dfs(count+1, a, b, c) dfs count+1 count 1 a b c y = dfs(count+1, a+l[count], b, c)+10 y dfs(count+1, a+l[count], b, c)+10 dfs(count+1, a+l[count], b, c) dfs count+1 count 1 a+l[count] a l[count] l count b c 10 z = dfs(count+1, a, b+l[count], c)+10 z dfs(count+1, a, b+l[count], c)+10 dfs(count+1, a, b+l[count], c) dfs count+1 count 1 a b+l[count] b l[count] l count c 10 w = dfs(count+1, a, b, c+l[count])+10 w dfs(count+1, a, b, c+l[count])+10 dfs(count+1, a, b, c+l[count]) dfs count+1 count 1 a b c+l[count] c l[count] l count 10 return min(x,y,z,w) min(x,y,z,w) min x y z w count count a a b b c c print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 B,C=map(int,input().split()) map(int,input().split()) B A,B,C=map(int,input().split()) map(int,input().split()) A C=map(int,input().split()) map(int,input().split()) C n,A,B,C=map(int,input().split()) map(int,input().split()) n def dfs(count,a,b,c):
    if count==n:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
    x = dfs(count+1, a, b, c)
    y = dfs(count+1, a+l[count], b, c)+10
    z = dfs(count+1, a, b+l[count], c)+10
    w = dfs(count+1, a, b, c+l[count])+10
    return min(x,y,z,w) def dfs(count,a,b,c):
    if count==n:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
    x = dfs(count+1, a, b, c)
    y = dfs(count+1, a+l[count], b, c)+10
    z = dfs(count+1, a, b+l[count], c)+10
    w = dfs(count+1, a, b, c+l[count])+10
    return min(x,y,z,w) dfs l=[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l
n,A,B,C=map(int,input().split())

l=[int(input()) for _ in range(n)]



def dfs(count,a,b,c):
    if count==n:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
    x = dfs(count+1, a, b, c)
    y = dfs(count+1, a+l[count], b, c)+10
    z = dfs(count+1, a, b+l[count], c)+10
    w = dfs(count+1, a, b, c+l[count])+10
    return min(x,y,z,w)



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