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


def dfs(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(A - a) + abs(B - b) + abs(C - c)
    res = dfs(i + 1, a, b, c)
    res = min([res, dfs(i + 1, a + l[i], b, c)])
    res = min([res, dfs(i + 1, a, b + l[i], c)])
    res = min([res, dfs(i + 1, a, b, c + l[i])])
    return res


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