# 解説を参考に作成


def solve():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for n in range(N)]

    def dfs(n=0, a=0, b=0, c=0, now_mp=0, min_mp=float('inf')):
        if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
        result1 = dfs(n + 1, a, b, c, now_mp, min_mp)
        result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp)
        result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp)
        result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp)
        return min(result1, result2, result3, result4)

    print(dfs())


if __name__ == '__main__':
    solve() def solve():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for n in range(N)]

    def dfs(n=0, a=0, b=0, c=0, now_mp=0, min_mp=float('inf')):
        if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
        result1 = dfs(n + 1, a, b, c, now_mp, min_mp)
        result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp)
        result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp)
        result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp)
        return min(result1, result2, result3, result4)

    print(dfs()) solve 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 n in range(N) for n in range(N) n range(N) range N for n in range(N) int(input()) int input() input ls = [int(input()) for n in range(N)] ls [int(input()) for n in range(N)] def dfs(n=0, a=0, b=0, c=0, now_mp=0, min_mp=float('inf')):
        if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
        result1 = dfs(n + 1, a, b, c, now_mp, min_mp)
        result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp)
        result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp)
        result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp)
        return min(result1, result2, result3, result4)

     dfs if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
         n == N n N if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
         0 in [a, b, c] 0 [a, b, c] a b c return min_mp min_mp return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp) min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp) min abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp abs(A - a) + abs(B - b) + abs(C - c) - 30 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 30 now_mp min_mp result1 = dfs(n + 1, a, b, c, now_mp, min_mp) result1 dfs(n + 1, a, b, c, now_mp, min_mp) dfs n + 1 n 1 a b c now_mp min_mp result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp) result2 dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp) dfs n + 1 n 1 a + ls[n] a ls[n] ls n b c now_mp + 10 now_mp 10 min_mp result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp) result3 dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp) dfs n + 1 n 1 a b + ls[n] b ls[n] ls n c now_mp + 10 now_mp 10 min_mp result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp) result4 dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp) dfs n + 1 n 1 a b c + ls[n] c ls[n] ls n now_mp + 10 now_mp 10 min_mp return min(result1, result2, result3, result4) min(result1, result2, result3, result4) min result1 result2 result3 result4 n=0 n 0 a=0 a 0 b=0 b 0 c=0 c 0 now_mp=0 now_mp 0 min_mp=float('inf') min_mp float('inf') float 'inf' print(dfs()) print dfs() dfs if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for n in range(N)]

    def dfs(n=0, a=0, b=0, c=0, now_mp=0, min_mp=float('inf')):
        if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
        result1 = dfs(n + 1, a, b, c, now_mp, min_mp)
        result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp)
        result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp)
        result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp)
        return min(result1, result2, result3, result4)

    print(dfs()) def solve():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for n in range(N)]

    def dfs(n=0, a=0, b=0, c=0, now_mp=0, min_mp=float('inf')):
        if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
        result1 = dfs(n + 1, a, b, c, now_mp, min_mp)
        result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp)
        result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp)
        result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp)
        return min(result1, result2, result3, result4)

    print(dfs()) solve
# 解説を参考に作成


def solve():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for n in range(N)]

    def dfs(n=0, a=0, b=0, c=0, now_mp=0, min_mp=float('inf')):
        if n == N:
            if 0 in [a, b, c]:
                return min_mp
            else:
                return min(abs(A - a) + abs(B - b) + abs(C - c) - 30 + now_mp,
                           min_mp)
        result1 = dfs(n + 1, a, b, c, now_mp, min_mp)
        result2 = dfs(n + 1, a + ls[n], b, c, now_mp + 10, min_mp)
        result3 = dfs(n + 1, a, b + ls[n], c, now_mp + 10, min_mp)
        result4 = dfs(n + 1, a, b, c + ls[n], now_mp + 10, min_mp)
        return min(result1, result2, result3, result4)

    print(dfs())


if __name__ == '__main__':
    solve()
