import sys
from itertools import product

n, *abc = map(int, sys.stdin.readline().split())
*l, = map(int, sys.stdin.read().split())

def main():
    cand = []
    for p in product([0, 1, 2, 3], repeat=n):
        group = [[] for _ in range(4)]
        for i in range(n):
            group[p[i]].append(l[i])
        cost = 0
        for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
    print(min(cand))

if __name__ ==  '__main__':
    main() import sys sys from itertools import product n, *abc = map(int, sys.stdin.readline().split()) n map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split *abc abc *l, = map(int, sys.stdin.read().split()) *l l map(int, sys.stdin.read().split()) map int sys.stdin.read().split() sys.stdin.read().split sys.stdin.read() sys.stdin.read sys.stdin sys stdin read split def main():
    cand = []
    for p in product([0, 1, 2, 3], repeat=n):
        group = [[] for _ in range(4)]
        for i in range(n):
            group[p[i]].append(l[i])
        cost = 0
        for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
    print(min(cand)) main cand = [] cand [] for p in product([0, 1, 2, 3], repeat=n):
        group = [[] for _ in range(4)]
        for i in range(n):
            group[p[i]].append(l[i])
        cost = 0
        for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
     p product([0, 1, 2, 3], repeat=n) product [0, 1, 2, 3] 0 1 2 3 repeat=n repeat n [] for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [] group = [[] for _ in range(4)] group [[] for _ in range(4)] for i in range(n):
            group[p[i]].append(l[i])
         i range(n) range n group[p[i]].append(l[i]) [p[i]].append [p[i]] group p[i] p i append l[i] l i cost = 0 cost 0 for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
     i range(1, 4) range 1 4 if not group[i]: 
                break
             not group[i] group[i] group i break cost += 10 * (len(group[i]) - 1) cost 10 * (len(group[i]) - 1) 10 len(group[i]) - 1 len(group[i]) len group[i] group i 1 group[i] = sum(group[i]) group[i] group i sum(group[i]) sum group[i] group i group = group[1:] group group[1:] group 1: 1 for i in range(3):
                cost += abs(abc[i] - group[i])
             i range(3) range 3 cost += abs(abc[i] - group[i]) cost abs(abc[i] - group[i]) abs abc[i] - group[i] abc[i] abc i group[i] group i cand.append(cost) cand.append cand append cost print(min(cand)) print min(cand) min cand if __name__ ==  '__main__':
    main() __name__ ==  '__main__' __name__ '__main__' main() main n, *abc = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n def main():
    cand = []
    for p in product([0, 1, 2, 3], repeat=n):
        group = [[] for _ in range(4)]
        for i in range(n):
            group[p[i]].append(l[i])
        cost = 0
        for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
    print(min(cand)) def main():
    cand = []
    for p in product([0, 1, 2, 3], repeat=n):
        group = [[] for _ in range(4)]
        for i in range(n):
            group[p[i]].append(l[i])
        cost = 0
        for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
    print(min(cand)) main
import sys
from itertools import product

n, *abc = map(int, sys.stdin.readline().split())
*l, = map(int, sys.stdin.read().split())

def main():
    cand = []
    for p in product([0, 1, 2, 3], repeat=n):
        group = [[] for _ in range(4)]
        for i in range(n):
            group[p[i]].append(l[i])
        cost = 0
        for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
    print(min(cand))

if __name__ ==  '__main__':
    main()