import sys
from itertools import product

input = sys.stdin.readline


def main():
    N, A, B, C = map(int, input().split())
    L = [0] * N
    for i in range(N):
        L[i] = int(input())

    ans = float("inf")
    for comb in product(range(4), repeat=N):
        mp = -30
        a = b = c = 0
        for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

        if min(a, b, c) == 0:
            continue

        mp += abs(A - a) + abs(B - b) + abs(C - c)
        if mp < ans:
            ans = mp

    print(ans)


if __name__ == "__main__":
    main() import sys sys from itertools import product input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N, A, B, C = map(int, input().split())
    L = [0] * N
    for i in range(N):
        L[i] = int(input())

    ans = float("inf")
    for comb in product(range(4), repeat=N):
        mp = -30
        a = b = c = 0
        for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

        if min(a, b, c) == 0:
            continue

        mp += abs(A - a) + abs(B - b) + abs(C - c)
        if mp < ans:
            ans = mp

    print(ans) main N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C L = [0] * N L [0] * N [0] 0 N for i in range(N):
        L[i] = int(input())

     i range(N) range N L[i] = int(input()) L[i] L i int(input()) int input() input ans = float("inf") ans float("inf") float "inf" for comb in product(range(4), repeat=N):
        mp = -30
        a = b = c = 0
        for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

        if min(a, b, c) == 0:
            continue

        mp += abs(A - a) + abs(B - b) + abs(C - c)
        if mp < ans:
            ans = mp

     comb product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N mp = -30 mp -30 a = b = c = 0 a 0 = b = c = 0 b 0 c for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

         i j enumerate(comb) enumerate comb if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
             j == 0 j 0 continue elif j == 1:
                a += L[i]
             j == 1 j 1 a += L[i] a L[i] L i elif j == 2:
                b += L[i]
             j == 2 j 2 b += L[i] b L[i] L i elif j == 3:
                c += L[i]
             j == 3 j 3 c += L[i] c L[i] L i mp += 10 mp 10 if min(a, b, c) == 0:
            continue

         min(a, b, c) == 0 min(a, b, c) min a b c 0 continue mp += abs(A - a) + abs(B - b) + abs(C - c) mp 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 if mp < ans:
            ans = mp

     mp < ans mp ans ans = mp ans mp print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, A, B, C = map(int, input().split())
    L = [0] * N
    for i in range(N):
        L[i] = int(input())

    ans = float("inf")
    for comb in product(range(4), repeat=N):
        mp = -30
        a = b = c = 0
        for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

        if min(a, b, c) == 0:
            continue

        mp += abs(A - a) + abs(B - b) + abs(C - c)
        if mp < ans:
            ans = mp

    print(ans) def main():
    N, A, B, C = map(int, input().split())
    L = [0] * N
    for i in range(N):
        L[i] = int(input())

    ans = float("inf")
    for comb in product(range(4), repeat=N):
        mp = -30
        a = b = c = 0
        for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

        if min(a, b, c) == 0:
            continue

        mp += abs(A - a) + abs(B - b) + abs(C - c)
        if mp < ans:
            ans = mp

    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys
from itertools import product

input = sys.stdin.readline


def main():
    N, A, B, C = map(int, input().split())
    L = [0] * N
    for i in range(N):
        L[i] = int(input())

    ans = float("inf")
    for comb in product(range(4), repeat=N):
        mp = -30
        a = b = c = 0
        for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

        if min(a, b, c) == 0:
            continue

        mp += abs(A - a) + abs(B - b) + abs(C - c)
        if mp < ans:
            ans = mp

    print(ans)


if __name__ == "__main__":
    main()
