N, A, B, C, *X = map(int, open(0).read().split())

def dfs(i, a, b, c):
    if i == N:
        if a * b * c == 0:
            return 10 ** 9 + 7
        return abs(A - a) + abs(B - b) + abs(C - c)

    v0 = dfs(i + 1, a, b, c)
    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10
    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10
    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10

    return min(v0, v1, v2, v3)


print(dfs(0, 0, 0, 0)) N, A, B, C, *X = map(int, open(0).read().split()) N map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split A B C *X X def dfs(i, a, b, c):
    if i == N:
        if a * b * c == 0:
            return 10 ** 9 + 7
        return abs(A - a) + abs(B - b) + abs(C - c)

    v0 = dfs(i + 1, a, b, c)
    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10
    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10
    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10

    return min(v0, v1, v2, v3) dfs if i == N:
        if a * b * c == 0:
            return 10 ** 9 + 7
        return abs(A - a) + abs(B - b) + abs(C - c)

     i == N i N if a * b * c == 0:
            return 10 ** 9 + 7
         a * b * c == 0 a * b * c a * b a b c 0 return 10 ** 9 + 7 10 ** 9 + 7 10 ** 9 10 9 7 return abs(A - a) + abs(B - b) + abs(C - 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 v0 = dfs(i + 1, a, b, c) v0 dfs(i + 1, a, b, c) dfs i + 1 i 1 a b c v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10 v1 dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10 dfs(i + 1, a + X[i], b, c) dfs i + 1 i 1 a + X[i] a X[i] X i b c int(a > 0) * 10 int(a > 0) int a > 0 a 0 10 v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10 v2 dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10 dfs(i + 1, a, b + X[i], c) dfs i + 1 i 1 a b + X[i] b X[i] X i c int(b > 0) * 10 int(b > 0) int b > 0 b 0 10 v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10 v3 dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10 dfs(i + 1, a, b, c + X[i]) dfs i + 1 i 1 a b c + X[i] c X[i] X i int(c > 0) * 10 int(c > 0) int c > 0 c 0 10 return min(v0, v1, v2, v3) min(v0, v1, v2, v3) min v0 v1 v2 v3 i i a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 def dfs(i, a, b, c):
    if i == N:
        if a * b * c == 0:
            return 10 ** 9 + 7
        return abs(A - a) + abs(B - b) + abs(C - c)

    v0 = dfs(i + 1, a, b, c)
    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10
    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10
    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10

    return min(v0, v1, v2, v3) def dfs(i, a, b, c):
    if i == N:
        if a * b * c == 0:
            return 10 ** 9 + 7
        return abs(A - a) + abs(B - b) + abs(C - c)

    v0 = dfs(i + 1, a, b, c)
    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10
    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10
    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10

    return min(v0, v1, v2, v3) dfs B, C, *X = map(int, open(0).read().split()) map(int, open(0).read().split()) B N, A, B, C, *X = map(int, open(0).read().split()) map(int, open(0).read().split()) N C, *X = map(int, open(0).read().split()) map(int, open(0).read().split()) C A, B, C, *X = map(int, open(0).read().split()) map(int, open(0).read().split()) A
N, A, B, C, *X = map(int, open(0).read().split())

def dfs(i, a, b, c):
    if i == N:
        if a * b * c == 0:
            return 10 ** 9 + 7
        return abs(A - a) + abs(B - b) + abs(C - c)

    v0 = dfs(i + 1, a, b, c)
    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10
    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10
    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10

    return min(v0, v1, v2, v3)


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