
from itertools import product

def main():
    n,a,b,c = map(int, input().split())
    targetl = [a,b,c]
    targetl.sort()
    ll = []
    for _ in range(n):
        l = int(input())
        ll.append(l)

    ans = 10**9
    ite = product(range(4),repeat=n)
    ite = list(ite)
    for it in ite:
        bamboosl = [ [],[],[] ]
        cost = -30
        for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

        continue_f = False    
        for bamboos in bamboosl:
            if not bamboos: continue_f = True
        if continue_f: continue

        longs = []
        for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
        longs.sort()

        for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
        ans = min(ans,cost)

    print(ans)


if __name__ == "__main__":
    main() from itertools import product def main():
    n,a,b,c = map(int, input().split())
    targetl = [a,b,c]
    targetl.sort()
    ll = []
    for _ in range(n):
        l = int(input())
        ll.append(l)

    ans = 10**9
    ite = product(range(4),repeat=n)
    ite = list(ite)
    for it in ite:
        bamboosl = [ [],[],[] ]
        cost = -30
        for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

        continue_f = False    
        for bamboos in bamboosl:
            if not bamboos: continue_f = True
        if continue_f: continue

        longs = []
        for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
        longs.sort()

        for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
        ans = min(ans,cost)

    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 targetl = [a,b,c] targetl [a,b,c] a b c targetl.sort() targetl.sort targetl sort ll = [] ll [] for _ in range(n):
        l = int(input())
        ll.append(l)

     _ range(n) range n l = int(input()) l int(input()) int input() input ll.append(l) ll.append ll append l ans = 10**9 ans 10**9 10 9 ite = product(range(4),repeat=n) ite product(range(4),repeat=n) product range(4) range 4 repeat=n repeat n ite = list(ite) ite list(ite) list ite for it in ite:
        bamboosl = [ [],[],[] ]
        cost = -30
        for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

        continue_f = False    
        for bamboos in bamboosl:
            if not bamboos: continue_f = True
        if continue_f: continue

        longs = []
        for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
        longs.sort()

        for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
        ans = min(ans,cost)

     it ite bamboosl = [ [],[],[] ] bamboosl [ [],[],[] ] [] [] [] cost = -30 cost -30 for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

         i v enumerate(it) enumerate it if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

         v != 3 v 3 bamboosl[v].append(ll[i]) [v].append [v] bamboosl v append ll[i] ll i cost += 10 cost 10 continue_f = False continue_f False for bamboos in bamboosl:
            if not bamboos: continue_f = True
         bamboos bamboosl if not bamboos: continue_f = True
         not bamboos bamboos if continue_f: continue

         continue_f longs = [] longs [] for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
         bamboos bamboosl curr_l = sum(bamboos) curr_l sum(bamboos) sum bamboos longs.append(curr_l) longs.append longs append curr_l longs.sort() longs.sort longs sort for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
         v1 v2 zip(targetl,longs) zip targetl longs cost += abs(v1-v2) cost abs(v1-v2) abs v1-v2 v1 v2 ans = min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n,a,b,c = map(int, input().split())
    targetl = [a,b,c]
    targetl.sort()
    ll = []
    for _ in range(n):
        l = int(input())
        ll.append(l)

    ans = 10**9
    ite = product(range(4),repeat=n)
    ite = list(ite)
    for it in ite:
        bamboosl = [ [],[],[] ]
        cost = -30
        for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

        continue_f = False    
        for bamboos in bamboosl:
            if not bamboos: continue_f = True
        if continue_f: continue

        longs = []
        for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
        longs.sort()

        for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
        ans = min(ans,cost)

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

    ans = 10**9
    ite = product(range(4),repeat=n)
    ite = list(ite)
    for it in ite:
        bamboosl = [ [],[],[] ]
        cost = -30
        for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

        continue_f = False    
        for bamboos in bamboosl:
            if not bamboos: continue_f = True
        if continue_f: continue

        longs = []
        for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
        longs.sort()

        for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
        ans = min(ans,cost)

    print(ans) main

from itertools import product

def main():
    n,a,b,c = map(int, input().split())
    targetl = [a,b,c]
    targetl.sort()
    ll = []
    for _ in range(n):
        l = int(input())
        ll.append(l)

    ans = 10**9
    ite = product(range(4),repeat=n)
    ite = list(ite)
    for it in ite:
        bamboosl = [ [],[],[] ]
        cost = -30
        for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

        continue_f = False    
        for bamboos in bamboosl:
            if not bamboos: continue_f = True
        if continue_f: continue

        longs = []
        for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
        longs.sort()

        for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
        ans = min(ans,cost)

    print(ans)


if __name__ == "__main__":
    main()