def min_mp(bls, A, B, C, a_used=False, b_used=False, c_used=False):
    if sum([a_used, b_used, c_used]) == 3:
        return 0
    else:
        min_val = 10**9  # large number
        non_used_num = 3 - sum([a_used, b_used, c_used])
        if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
        if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
        return min_val


def main():
    N, A, B, C = list(map(int, input().split(' ')))
    bls = [int(input()) for _ in range(N)]  # bamboo length
    print(min_mp(bls, A, B, C))


if __name__ == '__main__':
    main() def min_mp(bls, A, B, C, a_used=False, b_used=False, c_used=False):
    if sum([a_used, b_used, c_used]) == 3:
        return 0
    else:
        min_val = 10**9  # large number
        non_used_num = 3 - sum([a_used, b_used, c_used])
        if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
        if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
        return min_val min_mp if sum([a_used, b_used, c_used]) == 3:
        return 0
    else:
        min_val = 10**9  # large number
        non_used_num = 3 - sum([a_used, b_used, c_used])
        if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
        if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
        return min_val sum([a_used, b_used, c_used]) == 3 sum([a_used, b_used, c_used]) sum [a_used, b_used, c_used] a_used b_used c_used 3 return 0 0 min_val = 10**9 min_val 10**9 10 9 non_used_num = 3 - sum([a_used, b_used, c_used]) non_used_num 3 - sum([a_used, b_used, c_used]) 3 sum([a_used, b_used, c_used]) sum [a_used, b_used, c_used] a_used b_used c_used if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
         len(bls) - 1 >= non_used_num len(bls) - 1 len(bls) len bls 1 non_used_num min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ]) min_val min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ]) min [
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ] min_val min_mp(bls[1:], A, B, C, a_used, b_used, c_used) min_mp bls[1:] bls 1: 1 A B C a_used b_used c_used if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
         len(bls) > 0 len(bls) len bls 0 if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
             not a_used a_used min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ]) min_val min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ]) min [
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ] min_val abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used) abs(bls[0] - A) abs bls[0] - A bls[0] bls 0 A min_mp(bls[1:], A, B, C, not a_used, b_used, c_used) min_mp bls[1:] bls 1: 1 A B C not a_used a_used b_used c_used 10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used) 10 min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used) min_mp bls[1:] bls 1: 1 A - bls[0] A bls[0] bls 0 B C a_used b_used c_used if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
             not b_used b_used min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ]) min_val min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ]) min [
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ] min_val abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used) abs(bls[0] - B) abs bls[0] - B bls[0] bls 0 B min_mp(bls[1:], A, B, C, a_used, not b_used, c_used) min_mp bls[1:] bls 1: 1 A B C a_used not b_used b_used c_used 10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used) 10 min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used) min_mp bls[1:] bls 1: 1 A B - bls[0] B bls[0] bls 0 C a_used b_used c_used if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
         not c_used c_used min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ]) min_val min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ]) min [
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ] min_val abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used) abs(bls[0] - C) abs bls[0] - C bls[0] bls 0 C min_mp(bls[1:], A, B, C, a_used, b_used, not c_used) min_mp bls[1:] bls 1: 1 A B C a_used b_used not c_used c_used 10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used) 10 min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used) min_mp bls[1:] bls 1: 1 A B C - bls[0] C bls[0] bls 0 a_used b_used c_used return min_val min_val bls bls A A B B C C a_used=False a_used False b_used=False b_used False c_used=False c_used False def main():
    N, A, B, C = list(map(int, input().split(' ')))
    bls = [int(input()) for _ in range(N)]  # bamboo length
    print(min_mp(bls, A, B, C)) main N, A, B, C = list(map(int, input().split(' '))) N list(map(int, input().split(' '))) list 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 bls = [int(input()) for _ in range(N)] bls [int(input()) for _ in range(N)] print(min_mp(bls, A, B, C)) print min_mp(bls, A, B, C) min_mp bls A B C if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def min_mp(bls, A, B, C, a_used=False, b_used=False, c_used=False):
    if sum([a_used, b_used, c_used]) == 3:
        return 0
    else:
        min_val = 10**9  # large number
        non_used_num = 3 - sum([a_used, b_used, c_used])
        if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
        if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
        return min_val def min_mp(bls, A, B, C, a_used=False, b_used=False, c_used=False):
    if sum([a_used, b_used, c_used]) == 3:
        return 0
    else:
        min_val = 10**9  # large number
        non_used_num = 3 - sum([a_used, b_used, c_used])
        if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
        if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
        return min_val min_mp def main():
    N, A, B, C = list(map(int, input().split(' ')))
    bls = [int(input()) for _ in range(N)]  # bamboo length
    print(min_mp(bls, A, B, C)) def main():
    N, A, B, C = list(map(int, input().split(' ')))
    bls = [int(input()) for _ in range(N)]  # bamboo length
    print(min_mp(bls, A, B, C)) main
def min_mp(bls, A, B, C, a_used=False, b_used=False, c_used=False):
    if sum([a_used, b_used, c_used]) == 3:
        return 0
    else:
        min_val = 10**9  # large number
        non_used_num = 3 - sum([a_used, b_used, c_used])
        if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
        if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
        return min_val


def main():
    N, A, B, C = list(map(int, input().split(' ')))
    bls = [int(input()) for _ in range(N)]  # bamboo length
    print(min_mp(bls, A, B, C))


if __name__ == '__main__':
    main()
