import abc
import itertools

def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    i = 0
    mps = []
    for assign in itertools.product([0, 1, 2, 3], repeat=N):
        if 1 not in assign or 2 not in assign or 3 not in assign:
            continue
        mp = 0
        abc_length = {1: 0, 2: 0, 3: 0}
        for i, abc in enumerate(assign):
            if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

        for key, goal in zip([1, 2, 3], [A, B, C]):
            mp += abs(goal - abc_length[key])
        mps.append(mp)
    print(min(mps))


if __name__ == '__main__':
    main() import abc abc import itertools itertools def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    i = 0
    mps = []
    for assign in itertools.product([0, 1, 2, 3], repeat=N):
        if 1 not in assign or 2 not in assign or 3 not in assign:
            continue
        mp = 0
        abc_length = {1: 0, 2: 0, 3: 0}
        for i, abc in enumerate(assign):
            if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

        for key, goal in zip([1, 2, 3], [A, B, C]):
            mp += abs(goal - abc_length[key])
        mps.append(mp)
    print(min(mps)) main 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 L = [int(input()) for _ in range(N)] L [int(input()) for _ in range(N)] i = 0 i 0 mps = [] mps [] for assign in itertools.product([0, 1, 2, 3], repeat=N):
        if 1 not in assign or 2 not in assign or 3 not in assign:
            continue
        mp = 0
        abc_length = {1: 0, 2: 0, 3: 0}
        for i, abc in enumerate(assign):
            if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

        for key, goal in zip([1, 2, 3], [A, B, C]):
            mp += abs(goal - abc_length[key])
        mps.append(mp)
     assign itertools.product([0, 1, 2, 3], repeat=N) itertools.product itertools product [0, 1, 2, 3] 0 1 2 3 repeat=N repeat N if 1 not in assign or 2 not in assign or 3 not in assign:
            continue
         1 not in assign or 2 not in assign or 3 not in assign 1 not in assign or 2 not in assign 1 not in assign 1 assign 2 not in assign 2 assign 3 not in assign 3 assign continue mp = 0 mp 0 abc_length = {1: 0, 2: 0, 3: 0} abc_length {1: 0, 2: 0, 3: 0} 1 1 0 2 2 0 3 3 0 for i, abc in enumerate(assign):
            if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

         i abc enumerate(assign) enumerate assign if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

         abc == 0 abc 0 continue elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
             abc_length[abc] == 0 abc_length[abc] abc_length abc 0 abc_length[abc] = L[i] abc_length[abc] abc_length abc L[i] L i mp += 10 mp 10 abc_length[abc] += L[i] abc_length[abc] abc_length abc L[i] L i for key, goal in zip([1, 2, 3], [A, B, C]):
            mp += abs(goal - abc_length[key])
         key goal zip([1, 2, 3], [A, B, C]) zip [1, 2, 3] 1 2 3 [A, B, C] A B C mp += abs(goal - abc_length[key]) mp abs(goal - abc_length[key]) abs goal - abc_length[key] goal abc_length[key] abc_length key mps.append(mp) mps.append mps append mp print(min(mps)) print min(mps) min mps if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    i = 0
    mps = []
    for assign in itertools.product([0, 1, 2, 3], repeat=N):
        if 1 not in assign or 2 not in assign or 3 not in assign:
            continue
        mp = 0
        abc_length = {1: 0, 2: 0, 3: 0}
        for i, abc in enumerate(assign):
            if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

        for key, goal in zip([1, 2, 3], [A, B, C]):
            mp += abs(goal - abc_length[key])
        mps.append(mp)
    print(min(mps)) def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    i = 0
    mps = []
    for assign in itertools.product([0, 1, 2, 3], repeat=N):
        if 1 not in assign or 2 not in assign or 3 not in assign:
            continue
        mp = 0
        abc_length = {1: 0, 2: 0, 3: 0}
        for i, abc in enumerate(assign):
            if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

        for key, goal in zip([1, 2, 3], [A, B, C]):
            mp += abs(goal - abc_length[key])
        mps.append(mp)
    print(min(mps)) main
import abc
import itertools

def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    i = 0
    mps = []
    for assign in itertools.product([0, 1, 2, 3], repeat=N):
        if 1 not in assign or 2 not in assign or 3 not in assign:
            continue
        mp = 0
        abc_length = {1: 0, 2: 0, 3: 0}
        for i, abc in enumerate(assign):
            if abc == 0:
                continue
            elif abc_length[abc] == 0:
                abc_length[abc] = L[i]
            else:
                mp += 10
                abc_length[abc] += L[i]

        for key, goal in zip([1, 2, 3], [A, B, C]):
            mp += abs(goal - abc_length[key])
        mps.append(mp)
    print(min(mps))


if __name__ == '__main__':
    main()
