#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n,a,b,c = LI()
l = [I() for _ in range(n)]

s = a+b+c
ans = inf
for i in range(1<<n):
    lst = []
    t = 0
    for j in range(n):
        if i >> j & 1:
            t += 1
            lst.append(l[j])
    if t < 3:
        continue
    for j in range(3**t):
        tmp = '0'*t + Base_10_to_n(j,3)
        tmp = tmp[-t:]
        B = [0]*t
        for k in range(t):
            if str(tmp[k]) == '1':
                B[k] = 1
            elif str(tmp[k]) == '2':
                B[k] = 2
        X = [[],[],[]]
        for k in range(t):
            X[B[k]].append(lst[k])
        if len(X[0]) == 0:
            continue
        if len(X[1]) == 0:
            continue
        if len(X[2]) == 0:
            continue
        cost = abs(sum(X[0])-a)
        cost += abs(sum(X[1])-b)
        cost += abs(sum(X[2])-c)
        cost += 10*(len(X[0])-1)
        cost += 10*(len(X[1])-1)
        cost += 10*(len(X[2])-1)
        ans = min(ans,cost)
print(ans) import sys sys import math math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) sys.setrecursionlimit sys setrecursionlimit 2147483647 from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 inf = float('inf') inf float('inf') float 'inf' def I(): return int(sys.stdin.readline()) I def LI(): return list(map(int,sys.stdin.readline().split())) LI def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) Base_10_to_n if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
     int(X/n) int X/n X n return Base_10_to_n(int(X/n), n)+str(X%n) Base_10_to_n(int(X/n), n)+str(X%n) Base_10_to_n(int(X/n), n) Base_10_to_n int(X/n) int X/n X n n str(X%n) str X%n X n return str(X%n) str(X%n) str X%n X n X X n n n,a,b,c = LI() n LI() LI a b c I() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) I() I l = [I() for _ in range(n)] l [I() for _ in range(n)] s = a+b+c s a+b+c a+b a b c ans = inf ans inf for i in range(1<<n):
    lst = []
    t = 0
    for j in range(n):
        if i >> j & 1:
            t += 1
            lst.append(l[j])
    if t < 3:
        continue
    for j in range(3**t):
        tmp = '0'*t + Base_10_to_n(j,3)
        tmp = tmp[-t:]
        B = [0]*t
        for k in range(t):
            if str(tmp[k]) == '1':
                B[k] = 1
            elif str(tmp[k]) == '2':
                B[k] = 2
        X = [[],[],[]]
        for k in range(t):
            X[B[k]].append(lst[k])
        if len(X[0]) == 0:
            continue
        if len(X[1]) == 0:
            continue
        if len(X[2]) == 0:
            continue
        cost = abs(sum(X[0])-a)
        cost += abs(sum(X[1])-b)
        cost += abs(sum(X[2])-c)
        cost += 10*(len(X[0])-1)
        cost += 10*(len(X[1])-1)
        cost += 10*(len(X[2])-1)
        ans = min(ans,cost) i range(1<<n) range 1<<n 1 n lst = [] lst [] t = 0 t 0 for j in range(n):
        if i >> j & 1:
            t += 1
            lst.append(l[j])
     j range(n) range n if i >> j & 1:
            t += 1
            lst.append(l[j])
     i >> j & 1 i >> j i j 1 t += 1 t 1 lst.append(l[j]) lst.append lst append l[j] l j if t < 3:
        continue
     t < 3 t 3 continue for j in range(3**t):
        tmp = '0'*t + Base_10_to_n(j,3)
        tmp = tmp[-t:]
        B = [0]*t
        for k in range(t):
            if str(tmp[k]) == '1':
                B[k] = 1
            elif str(tmp[k]) == '2':
                B[k] = 2
        X = [[],[],[]]
        for k in range(t):
            X[B[k]].append(lst[k])
        if len(X[0]) == 0:
            continue
        if len(X[1]) == 0:
            continue
        if len(X[2]) == 0:
            continue
        cost = abs(sum(X[0])-a)
        cost += abs(sum(X[1])-b)
        cost += abs(sum(X[2])-c)
        cost += 10*(len(X[0])-1)
        cost += 10*(len(X[1])-1)
        cost += 10*(len(X[2])-1)
        ans = min(ans,cost) j range(3**t) range 3**t 3 t tmp = '0'*t + Base_10_to_n(j,3) tmp '0'*t + Base_10_to_n(j,3) '0'*t '0' t Base_10_to_n(j,3) Base_10_to_n j 3 tmp = tmp[-t:] tmp tmp[-t:] tmp -t: -t t B = [0]*t B [0]*t [0] 0 t for k in range(t):
            if str(tmp[k]) == '1':
                B[k] = 1
            elif str(tmp[k]) == '2':
                B[k] = 2
         k range(t) range t if str(tmp[k]) == '1':
                B[k] = 1
            elif str(tmp[k]) == '2':
                B[k] = 2
         str(tmp[k]) == '1' str(tmp[k]) str tmp[k] tmp k '1' B[k] = 1 B[k] B k 1 elif str(tmp[k]) == '2':
                B[k] = 2
         str(tmp[k]) == '2' str(tmp[k]) str tmp[k] tmp k '2' B[k] = 2 B[k] B k 2 X = [[],[],[]] X [[],[],[]] [] [] [] for k in range(t):
            X[B[k]].append(lst[k])
         k range(t) range t X[B[k]].append(lst[k]) [B[k]].append [B[k]] X B[k] B k append lst[k] lst k if len(X[0]) == 0:
            continue
         len(X[0]) == 0 len(X[0]) len X[0] X 0 0 continue if len(X[1]) == 0:
            continue
         len(X[1]) == 0 len(X[1]) len X[1] X 1 0 continue if len(X[2]) == 0:
            continue
         len(X[2]) == 0 len(X[2]) len X[2] X 2 0 continue cost = abs(sum(X[0])-a) cost abs(sum(X[0])-a) abs sum(X[0])-a sum(X[0]) sum X[0] X 0 a cost += abs(sum(X[1])-b) cost abs(sum(X[1])-b) abs sum(X[1])-b sum(X[1]) sum X[1] X 1 b cost += abs(sum(X[2])-c) cost abs(sum(X[2])-c) abs sum(X[2])-c sum(X[2]) sum X[2] X 2 c cost += 10*(len(X[0])-1) cost 10*(len(X[0])-1) 10 len(X[0])-1 len(X[0]) len X[0] X 0 1 cost += 10*(len(X[1])-1) cost 10*(len(X[1])-1) 10 len(X[1])-1 len(X[1]) len X[1] X 1 1 cost += 10*(len(X[2])-1) cost 10*(len(X[2])-1) 10 len(X[2])-1 len(X[2]) len X[2] X 2 1 ans = min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans cost = abs(sum(X[0])-a) abs(sum(X[0])-a) cost t = 0 0 t t += 1 1 t tmp = '0'*t + Base_10_to_n(j,3) '0'*t + Base_10_to_n(j,3) tmp cost += 10*(len(X[1])-1) 10*(len(X[1])-1) cost mod = 10**9 + 7 10**9 + 7 mod n,a,b,c = LI() LI() n def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) Base_10_to_n tmp = tmp[-t:] tmp[-t:] tmp cost += 10*(len(X[0])-1) 10*(len(X[0])-1) cost X = [[],[],[]] [[],[],[]] X ans = inf inf ans B = [0]*t [0]*t B def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I a,b,c = LI() LI() a cost += abs(sum(X[2])-c) abs(sum(X[2])-c) cost b,c = LI() LI() b inf = float('inf') float('inf') inf c = LI() LI() c lst = [] [] lst s = a+b+c a+b+c s cost += abs(sum(X[1])-b) abs(sum(X[1])-b) cost cost += 10*(len(X[2])-1) 10*(len(X[2])-1) cost ans = min(ans,cost) min(ans,cost) ans def LI(): return list(map(int,sys.stdin.readline().split())) def LI(): return list(map(int,sys.stdin.readline().split())) LI l = [I() for _ in range(n)] [I() for _ in range(n)] l
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n,a,b,c = LI()
l = [I() for _ in range(n)]

s = a+b+c
ans = inf
for i in range(1<<n):
    lst = []
    t = 0
    for j in range(n):
        if i >> j & 1:
            t += 1
            lst.append(l[j])
    if t < 3:
        continue
    for j in range(3**t):
        tmp = '0'*t + Base_10_to_n(j,3)
        tmp = tmp[-t:]
        B = [0]*t
        for k in range(t):
            if str(tmp[k]) == '1':
                B[k] = 1
            elif str(tmp[k]) == '2':
                B[k] = 2
        X = [[],[],[]]
        for k in range(t):
            X[B[k]].append(lst[k])
        if len(X[0]) == 0:
            continue
        if len(X[1]) == 0:
            continue
        if len(X[2]) == 0:
            continue
        cost = abs(sum(X[0])-a)
        cost += abs(sum(X[1])-b)
        cost += abs(sum(X[2])-c)
        cost += 10*(len(X[0])-1)
        cost += 10*(len(X[1])-1)
        cost += 10*(len(X[2])-1)
        ans = min(ans,cost)
print(ans)