
N, A, B, C = map(int, input().split())
X = [int(input()) for _ in range(N)]


def dfs(idx, a, b, c, cnt):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

    res = 10 ** 9
    res = min(res, dfs(idx + 1, a, b, c, cnt))
    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))
    return res


print(dfs(0, 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 X = [int(input()) for _ in range(N)] X [int(input()) for _ in range(N)] def dfs(idx, a, b, c, cnt):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

    res = 10 ** 9
    res = min(res, dfs(idx + 1, a, b, c, cnt))
    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))
    return res dfs if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

     idx == N idx N if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

     min(a, b, c) > 0 min(a, b, c) min a b c 0 return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30 abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30 abs(a - A) + abs(b - B) + abs(c - C) + cnt 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 cnt 30 return 10 ** 9 10 ** 9 10 9 res = 10 ** 9 res 10 ** 9 10 9 res = min(res, dfs(idx + 1, a, b, c, cnt)) res min(res, dfs(idx + 1, a, b, c, cnt)) min res dfs(idx + 1, a, b, c, cnt) dfs idx + 1 idx 1 a b c cnt res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10)) res min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10)) min res dfs(idx + 1, a + X[idx], b, c, cnt + 10) dfs idx + 1 idx 1 a + X[idx] a X[idx] X idx b c cnt + 10 cnt 10 res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10)) res min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10)) min res dfs(idx + 1, a, b + X[idx], c, cnt + 10) dfs idx + 1 idx 1 a b + X[idx] b X[idx] X idx c cnt + 10 cnt 10 res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10)) res min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10)) min res dfs(idx + 1, a, b, c + X[idx], cnt + 10) dfs idx + 1 idx 1 a b c + X[idx] c X[idx] X idx cnt + 10 cnt 10 return res res idx idx a a b b c c cnt cnt print(dfs(0, 0, 0, 0, 0)) print dfs(0, 0, 0, 0, 0) dfs 0 0 0 0 0 N, A, B, C = map(int, input().split()) map(int, input().split()) N X = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] X C = map(int, input().split()) map(int, input().split()) C def dfs(idx, a, b, c, cnt):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

    res = 10 ** 9
    res = min(res, dfs(idx + 1, a, b, c, cnt))
    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))
    return res def dfs(idx, a, b, c, cnt):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

    res = 10 ** 9
    res = min(res, dfs(idx + 1, a, b, c, cnt))
    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))
    return res dfs A, B, C = map(int, input().split()) map(int, input().split()) A B, C = map(int, input().split()) map(int, input().split()) B

N, A, B, C = map(int, input().split())
X = [int(input()) for _ in range(N)]


def dfs(idx, a, b, c, cnt):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

    res = 10 ** 9
    res = min(res, dfs(idx + 1, a, b, c, cnt))
    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))
    return res


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