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