def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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


    res = 10**20
    #各竹について0~3で場合分け
    for s in range(1<<(2*n)):
        l1 = []
        l2 = []
        l3 = []
        mp = 0
        #iセット目(i本目)
        for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
        d, e, f = len(l1), len(l2), len(l3)
        if d==0 or e==0 or f==0:
            continue
        mp += (d+e+f-3)*10
        mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c)
        res = min(res, mp)
    print(res)

if __name__ == '__main__':
    main() def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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


    res = 10**20
    #各竹について0~3で場合分け
    for s in range(1<<(2*n)):
        l1 = []
        l2 = []
        l3 = []
        mp = 0
        #iセット目(i本目)
        for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
        d, e, f = len(l1), len(l2), len(l3)
        if d==0 or e==0 or f==0:
            continue
        mp += (d+e+f-3)*10
        mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c)
        res = min(res, mp)
    print(res) main import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from itertools import combinations, permutations, accumulate, groupby from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil 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)] res = 10**20 res 10**20 10 20 for s in range(1<<(2*n)):
        l1 = []
        l2 = []
        l3 = []
        mp = 0
        #iセット目(i本目)
        for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
        d, e, f = len(l1), len(l2), len(l3)
        if d==0 or e==0 or f==0:
            continue
        mp += (d+e+f-3)*10
        mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c)
        res = min(res, mp)
     s range(1<<(2*n)) range 1<<(2*n) 1 2*n 2 n l1 = [] l1 [] l2 = [] l2 [] l3 = [] l3 [] mp = 0 mp 0 for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
         i range(0, 2*n, 2) range 0 2*n 2 n 2 num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2 num (s>>i) & 1 + ((s>>(i+1)) & 1)*2 s>>i s i 1 + ((s>>(i+1)) & 1)*2 1 ((s>>(i+1)) & 1)*2 (s>>(i+1)) & 1 s>>(i+1) s i+1 i 1 1 2 if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
         num==1 num 1 l1.append(l[i//2]) l1.append l1 append l[i//2] l i//2 i 2 elif num==2:
                l2.append(l[i//2])
             num==2 num 2 l2.append(l[i//2]) l2.append l2 append l[i//2] l i//2 i 2 elif num==3:
                l3.append(l[i//2])
         num==3 num 3 l3.append(l[i//2]) l3.append l3 append l[i//2] l i//2 i 2 d, e, f = len(l1), len(l2), len(l3) d len(l1) len l1 e len(l2) len l2 f len(l3) len l3 if d==0 or e==0 or f==0:
            continue
         d==0 or e==0 or f==0 d==0 or e==0 d==0 d 0 e==0 e 0 f==0 f 0 continue mp += (d+e+f-3)*10 mp (d+e+f-3)*10 d+e+f-3 d+e+f d+e d e f 3 10 mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c) mp abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c) abs(sum(l1)-a) + abs(sum(l2)-b) abs(sum(l1)-a) abs sum(l1)-a sum(l1) sum l1 a abs(sum(l2)-b) abs sum(l2)-b sum(l2) sum l2 b abs(sum(l3)-c) abs sum(l3)-c sum(l3) sum l3 c res = min(res, mp) res min(res, mp) min res mp print(res) print res if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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


    res = 10**20
    #各竹について0~3で場合分け
    for s in range(1<<(2*n)):
        l1 = []
        l2 = []
        l3 = []
        mp = 0
        #iセット目(i本目)
        for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
        d, e, f = len(l1), len(l2), len(l3)
        if d==0 or e==0 or f==0:
            continue
        mp += (d+e+f-3)*10
        mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c)
        res = min(res, mp)
    print(res) def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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


    res = 10**20
    #各竹について0~3で場合分け
    for s in range(1<<(2*n)):
        l1 = []
        l2 = []
        l3 = []
        mp = 0
        #iセット目(i本目)
        for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
        d, e, f = len(l1), len(l2), len(l3)
        if d==0 or e==0 or f==0:
            continue
        mp += (d+e+f-3)*10
        mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c)
        res = min(res, mp)
    print(res) main
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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


    res = 10**20
    #各竹について0~3で場合分け
    for s in range(1<<(2*n)):
        l1 = []
        l2 = []
        l3 = []
        mp = 0
        #iセット目(i本目)
        for i in range(0, 2*n, 2):
            num = (s>>i) & 1 + ((s>>(i+1)) & 1)*2
            if num==1:
                l1.append(l[i//2])
            elif num==2:
                l2.append(l[i//2])
            elif num==3:
                l3.append(l[i//2])
        d, e, f = len(l1), len(l2), len(l3)
        if d==0 or e==0 or f==0:
            continue
        mp += (d+e+f-3)*10
        mp += abs(sum(l1)-a) + abs(sum(l2)-b) + abs(sum(l3)-c)
        res = min(res, mp)
    print(res)

if __name__ == '__main__':
    main()