import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, a, b, c = list(map(int, readline().split()))
    l = [int(input()) for _ in range(n)]

    ans = INF

    selects = list(itertools.product(range(4), repeat=n))

    for select in selects:
        mp = -30
        bamboo_length = [0] * 3
        for i, num in enumerate(select):
            if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

        for length in bamboo_length:
            if length == 0:
                break
        else:
            mp += abs(a - bamboo_length[0])
            mp += abs(b - bamboo_length[1])
            mp += abs(c - bamboo_length[2])
            ans = min(mp, ans)

    print(ans)


if __name__ == '__main__':
    main() import sys sys import itertools itertools readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    n, a, b, c = list(map(int, readline().split()))
    l = [int(input()) for _ in range(n)]

    ans = INF

    selects = list(itertools.product(range(4), repeat=n))

    for select in selects:
        mp = -30
        bamboo_length = [0] * 3
        for i, num in enumerate(select):
            if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

        for length in bamboo_length:
            if length == 0:
                break
        else:
            mp += abs(a - bamboo_length[0])
            mp += abs(b - bamboo_length[1])
            mp += abs(c - bamboo_length[2])
            ans = min(mp, ans)

    print(ans) main n, a, b, c = list(map(int, readline().split())) n list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline 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)] ans = INF ans INF selects = list(itertools.product(range(4), repeat=n)) selects list(itertools.product(range(4), repeat=n)) list itertools.product(range(4), repeat=n) itertools.product itertools product range(4) range 4 repeat=n repeat n for select in selects:
        mp = -30
        bamboo_length = [0] * 3
        for i, num in enumerate(select):
            if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

        for length in bamboo_length:
            if length == 0:
                break
        else:
            mp += abs(a - bamboo_length[0])
            mp += abs(b - bamboo_length[1])
            mp += abs(c - bamboo_length[2])
            ans = min(mp, ans)

     select selects mp = -30 mp -30 bamboo_length = [0] * 3 bamboo_length [0] * 3 [0] 0 3 for i, num in enumerate(select):
            if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

         i num enumerate(select) enumerate select if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

         num != 3 num 3 bamboo_length[num] += l[i] bamboo_length[num] bamboo_length num l[i] l i mp += 10 mp 10 for length in bamboo_length:
            if length == 0:
                break
        else:
            mp += abs(a - bamboo_length[0])
            mp += abs(b - bamboo_length[1])
            mp += abs(c - bamboo_length[2])
            ans = min(mp, ans)

     length bamboo_length if length == 0:
                break
         length == 0 length 0 break mp += abs(a - bamboo_length[0]) mp abs(a - bamboo_length[0]) abs a - bamboo_length[0] a bamboo_length[0] bamboo_length 0 mp += abs(b - bamboo_length[1]) mp abs(b - bamboo_length[1]) abs b - bamboo_length[1] b bamboo_length[1] bamboo_length 1 mp += abs(c - bamboo_length[2]) mp abs(c - bamboo_length[2]) abs c - bamboo_length[2] c bamboo_length[2] bamboo_length 2 ans = min(mp, ans) ans min(mp, ans) min mp ans print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, a, b, c = list(map(int, readline().split()))
    l = [int(input()) for _ in range(n)]

    ans = INF

    selects = list(itertools.product(range(4), repeat=n))

    for select in selects:
        mp = -30
        bamboo_length = [0] * 3
        for i, num in enumerate(select):
            if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

        for length in bamboo_length:
            if length == 0:
                break
        else:
            mp += abs(a - bamboo_length[0])
            mp += abs(b - bamboo_length[1])
            mp += abs(c - bamboo_length[2])
            ans = min(mp, ans)

    print(ans) def main():
    n, a, b, c = list(map(int, readline().split()))
    l = [int(input()) for _ in range(n)]

    ans = INF

    selects = list(itertools.product(range(4), repeat=n))

    for select in selects:
        mp = -30
        bamboo_length = [0] * 3
        for i, num in enumerate(select):
            if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

        for length in bamboo_length:
            if length == 0:
                break
        else:
            mp += abs(a - bamboo_length[0])
            mp += abs(b - bamboo_length[1])
            mp += abs(c - bamboo_length[2])
            ans = min(mp, ans)

    print(ans) main readline = sys.stdin.readline sys.stdin.readline readline INF = float('INF') float('INF') INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, a, b, c = list(map(int, readline().split()))
    l = [int(input()) for _ in range(n)]

    ans = INF

    selects = list(itertools.product(range(4), repeat=n))

    for select in selects:
        mp = -30
        bamboo_length = [0] * 3
        for i, num in enumerate(select):
            if num != 3:
                bamboo_length[num] += l[i]
                mp += 10

        for length in bamboo_length:
            if length == 0:
                break
        else:
            mp += abs(a - bamboo_length[0])
            mp += abs(b - bamboo_length[1])
            mp += abs(c - bamboo_length[2])
            ans = min(mp, ans)

    print(ans)


if __name__ == '__main__':
    main()
