N,A,B,C = list(map(int,input().split()))
l = []
for i in range(N):
    l.append(int(input()))

choiceList = []
for i in range(4 ** N):
    choice = [-1 for i in range(N)]
    for j in range (N):
        choice[j] = i // (4 ** j) % 4
    choiceList.append(choice)

minCost = 10 ** 9
for choice in choiceList:
    cost = 10 ** 9
    aList = []
    bList = []
    cList = []
    for i in range(N):
        if choice[i] == 1:
            aList.append(l[i])
        elif choice[i] == 2:
            bList.append(l[i])
        elif choice[i] == 3:
            cList.append(l[i])
    if len(aList) == 0 or len(bList) == 0 or len(cList) == 0:
        cost = 10 ** 9
    else:
        aCost = (len(aList) - 1) * 10 + abs(sum(aList) - A)
        bCost = (len(bList) - 1) * 10 + abs(sum(bList) - B)
        cCost = (len(cList) - 1) * 10 + abs(sum(cList) - C)
        cost = aCost + bCost + cCost
    if minCost > cost:
        minCost = cost

print(minCost) 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 l = [] l [] for i in range(N):
    l.append(int(input())) i range(N) range N l.append(int(input())) l.append l append int(input()) int input() input choiceList = [] choiceList [] for i in range(4 ** N):
    choice = [-1 for i in range(N)]
    for j in range (N):
        choice[j] = i // (4 ** j) % 4
    choiceList.append(choice) i range(4 ** N) range 4 ** N 4 N -1 for i in range(N) for i in range(N) i range(N) range N for i in range(N) -1 choice = [-1 for i in range(N)] choice [-1 for i in range(N)] for j in range (N):
        choice[j] = i // (4 ** j) % 4
     j range (N) range N choice[j] = i // (4 ** j) % 4 choice[j] choice j i // (4 ** j) % 4 i // (4 ** j) i 4 ** j 4 j 4 choiceList.append(choice) choiceList.append choiceList append choice minCost = 10 ** 9 minCost 10 ** 9 10 9 for choice in choiceList:
    cost = 10 ** 9
    aList = []
    bList = []
    cList = []
    for i in range(N):
        if choice[i] == 1:
            aList.append(l[i])
        elif choice[i] == 2:
            bList.append(l[i])
        elif choice[i] == 3:
            cList.append(l[i])
    if len(aList) == 0 or len(bList) == 0 or len(cList) == 0:
        cost = 10 ** 9
    else:
        aCost = (len(aList) - 1) * 10 + abs(sum(aList) - A)
        bCost = (len(bList) - 1) * 10 + abs(sum(bList) - B)
        cCost = (len(cList) - 1) * 10 + abs(sum(cList) - C)
        cost = aCost + bCost + cCost
    if minCost > cost:
        minCost = cost choice choiceList cost = 10 ** 9 cost 10 ** 9 10 9 aList = [] aList [] bList = [] bList [] cList = [] cList [] for i in range(N):
        if choice[i] == 1:
            aList.append(l[i])
        elif choice[i] == 2:
            bList.append(l[i])
        elif choice[i] == 3:
            cList.append(l[i])
     i range(N) range N if choice[i] == 1:
            aList.append(l[i])
        elif choice[i] == 2:
            bList.append(l[i])
        elif choice[i] == 3:
            cList.append(l[i])
     choice[i] == 1 choice[i] choice i 1 aList.append(l[i]) aList.append aList append l[i] l i elif choice[i] == 2:
            bList.append(l[i])
         choice[i] == 2 choice[i] choice i 2 bList.append(l[i]) bList.append bList append l[i] l i elif choice[i] == 3:
            cList.append(l[i])
     choice[i] == 3 choice[i] choice i 3 cList.append(l[i]) cList.append cList append l[i] l i if len(aList) == 0 or len(bList) == 0 or len(cList) == 0:
        cost = 10 ** 9
    else:
        aCost = (len(aList) - 1) * 10 + abs(sum(aList) - A)
        bCost = (len(bList) - 1) * 10 + abs(sum(bList) - B)
        cCost = (len(cList) - 1) * 10 + abs(sum(cList) - C)
        cost = aCost + bCost + cCost
     len(aList) == 0 or len(bList) == 0 or len(cList) == 0 len(aList) == 0 or len(bList) == 0 len(aList) == 0 len(aList) len aList 0 len(bList) == 0 len(bList) len bList 0 len(cList) == 0 len(cList) len cList 0 cost = 10 ** 9 cost 10 ** 9 10 9 aCost = (len(aList) - 1) * 10 + abs(sum(aList) - A) aCost (len(aList) - 1) * 10 + abs(sum(aList) - A) (len(aList) - 1) * 10 len(aList) - 1 len(aList) len aList 1 10 abs(sum(aList) - A) abs sum(aList) - A sum(aList) sum aList A bCost = (len(bList) - 1) * 10 + abs(sum(bList) - B) bCost (len(bList) - 1) * 10 + abs(sum(bList) - B) (len(bList) - 1) * 10 len(bList) - 1 len(bList) len bList 1 10 abs(sum(bList) - B) abs sum(bList) - B sum(bList) sum bList B cCost = (len(cList) - 1) * 10 + abs(sum(cList) - C) cCost (len(cList) - 1) * 10 + abs(sum(cList) - C) (len(cList) - 1) * 10 len(cList) - 1 len(cList) len cList 1 10 abs(sum(cList) - C) abs sum(cList) - C sum(cList) sum cList C cost = aCost + bCost + cCost cost aCost + bCost + cCost aCost + bCost aCost bCost cCost if minCost > cost:
        minCost = cost minCost > cost minCost cost minCost = cost minCost cost print(minCost) print minCost l = [] [] l minCost = 10 ** 9 10 ** 9 minCost aList = [] [] aList A,B,C = list(map(int,input().split())) list(map(int,input().split())) A bList = [] [] bList choice = [-1 for i in range(N)] [-1 for i in range(N)] choice aCost = (len(aList) - 1) * 10 + abs(sum(aList) - A) (len(aList) - 1) * 10 + abs(sum(aList) - A) aCost cList = [] [] cList N,A,B,C = list(map(int,input().split())) list(map(int,input().split())) N bCost = (len(bList) - 1) * 10 + abs(sum(bList) - B) (len(bList) - 1) * 10 + abs(sum(bList) - B) bCost minCost = cost cost minCost B,C = list(map(int,input().split())) list(map(int,input().split())) B C = list(map(int,input().split())) list(map(int,input().split())) C choiceList = [] [] choiceList cCost = (len(cList) - 1) * 10 + abs(sum(cList) - C) (len(cList) - 1) * 10 + abs(sum(cList) - C) cCost cost = aCost + bCost + cCost aCost + bCost + cCost cost cost = 10 ** 9 10 ** 9 cost cost = 10 ** 9 10 ** 9 cost
N,A,B,C = list(map(int,input().split()))
l = []
for i in range(N):
    l.append(int(input()))

choiceList = []
for i in range(4 ** N):
    choice = [-1 for i in range(N)]
    for j in range (N):
        choice[j] = i // (4 ** j) % 4
    choiceList.append(choice)

minCost = 10 ** 9
for choice in choiceList:
    cost = 10 ** 9
    aList = []
    bList = []
    cList = []
    for i in range(N):
        if choice[i] == 1:
            aList.append(l[i])
        elif choice[i] == 2:
            bList.append(l[i])
        elif choice[i] == 3:
            cList.append(l[i])
    if len(aList) == 0 or len(bList) == 0 or len(cList) == 0:
        cost = 10 ** 9
    else:
        aCost = (len(aList) - 1) * 10 + abs(sum(aList) - A)
        bCost = (len(bList) - 1) * 10 + abs(sum(bList) - B)
        cCost = (len(cList) - 1) * 10 + abs(sum(cList) - C)
        cost = aCost + bCost + cCost
    if minCost > cost:
        minCost = cost

print(minCost)