n, a, b, c = map(int,input().split())
l = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(i, x, y, z):
    if i == n:
        cand = abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF
        return cand

    temp0 = dfs(i + 1, x + l[i], y, z) + 10
    temp1 = dfs(i + 1, x, y + l[i], z) + 10
    temp2 = dfs(i + 1, x, y, z + l[i]) + 10
    temp3 = dfs(i + 1, x, y, z)
    return min(temp0, temp1, temp2, temp3)

ans = dfs(0,0,0,0)
print(ans) 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 i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] INF = 10 ** 9 INF 10 ** 9 10 9 def dfs(i, x, y, z):
    if i == n:
        cand = abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF
        return cand

    temp0 = dfs(i + 1, x + l[i], y, z) + 10
    temp1 = dfs(i + 1, x, y + l[i], z) + 10
    temp2 = dfs(i + 1, x, y, z + l[i]) + 10
    temp3 = dfs(i + 1, x, y, z)
    return min(temp0, temp1, temp2, temp3) dfs if i == n:
        cand = abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF
        return cand

     i == n i n cand = abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF cand abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF 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 INF return cand cand temp0 = dfs(i + 1, x + l[i], y, z) + 10 temp0 dfs(i + 1, x + l[i], y, z) + 10 dfs(i + 1, x + l[i], y, z) dfs i + 1 i 1 x + l[i] x l[i] l i y z 10 temp1 = dfs(i + 1, x, y + l[i], z) + 10 temp1 dfs(i + 1, x, y + l[i], z) + 10 dfs(i + 1, x, y + l[i], z) dfs i + 1 i 1 x y + l[i] y l[i] l i z 10 temp2 = dfs(i + 1, x, y, z + l[i]) + 10 temp2 dfs(i + 1, x, y, z + l[i]) + 10 dfs(i + 1, x, y, z + l[i]) dfs i + 1 i 1 x y z + l[i] z l[i] l i 10 temp3 = dfs(i + 1, x, y, z) temp3 dfs(i + 1, x, y, z) dfs i + 1 i 1 x y z return min(temp0, temp1, temp2, temp3) min(temp0, temp1, temp2, temp3) min temp0 temp1 temp2 temp3 i i x x y y z z ans = dfs(0,0,0,0) ans dfs(0,0,0,0) dfs 0 0 0 0 print(ans) print ans ans = dfs(0,0,0,0) dfs(0,0,0,0) ans n, a, b, c = map(int,input().split()) map(int,input().split()) n INF = 10 ** 9 10 ** 9 INF c = map(int,input().split()) map(int,input().split()) c b, c = map(int,input().split()) map(int,input().split()) b def dfs(i, x, y, z):
    if i == n:
        cand = abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF
        return cand

    temp0 = dfs(i + 1, x + l[i], y, z) + 10
    temp1 = dfs(i + 1, x, y + l[i], z) + 10
    temp2 = dfs(i + 1, x, y, z + l[i]) + 10
    temp3 = dfs(i + 1, x, y, z)
    return min(temp0, temp1, temp2, temp3) def dfs(i, x, y, z):
    if i == n:
        cand = abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF
        return cand

    temp0 = dfs(i + 1, x + l[i], y, z) + 10
    temp1 = dfs(i + 1, x, y + l[i], z) + 10
    temp2 = dfs(i + 1, x, y, z + l[i]) + 10
    temp3 = dfs(i + 1, x, y, z)
    return min(temp0, temp1, temp2, temp3) dfs l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l a, b, c = map(int,input().split()) map(int,input().split()) a
n, a, b, c = map(int,input().split())
l = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(i, x, y, z):
    if i == n:
        cand = abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF
        return cand

    temp0 = dfs(i + 1, x + l[i], y, z) + 10
    temp1 = dfs(i + 1, x, y + l[i], z) + 10
    temp2 = dfs(i + 1, x, y, z + l[i]) + 10
    temp3 = dfs(i + 1, x, y, z)
    return min(temp0, temp1, temp2, temp3)

ans = dfs(0,0,0,0)
print(ans)