n,a,b,c=map(int,input().split())
l = []
for i in range(n):
  l.append(int(input()))
m = [a,b,c]
ans = 4000
for i in range(4**n):
  p = [0]*n
  k = i
  for j in range(n):
    p[j] = k % 4
    k //= 4
  cost = [-1,-1,-1]
  q = [[] for _ in range(4)]
  for j in range(n):
    q[p[j]].append(l[j])
  for j in range(3):
    if len(q[j+1]) != 0:
      cost[j] = 10 * (len(q[j+1]) - 1) + abs(sum(q[j+1])-m[j])
  if cost[0] != -1 and cost[1] != -1 and cost[2] != -1:
    ans = min(ans, cost[0] + cost[1] + cost[2])
print(ans) n,a,b,c=map(int,input().split()) n 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 m = [a,b,c] m [a,b,c] a b c ans = 4000 ans 4000 for i in range(4**n):
  p = [0]*n
  k = i
  for j in range(n):
    p[j] = k % 4
    k //= 4
  cost = [-1,-1,-1]
  q = [[] for _ in range(4)]
  for j in range(n):
    q[p[j]].append(l[j])
  for j in range(3):
    if len(q[j+1]) != 0:
      cost[j] = 10 * (len(q[j+1]) - 1) + abs(sum(q[j+1])-m[j])
  if cost[0] != -1 and cost[1] != -1 and cost[2] != -1:
    ans = min(ans, cost[0] + cost[1] + cost[2]) i range(4**n) range 4**n 4 n p = [0]*n p [0]*n [0] 0 n k = i k i for j in range(n):
    p[j] = k % 4
    k //= 4
   j range(n) range n p[j] = k % 4 p[j] p j k % 4 k 4 k //= 4 k 4 cost = [-1,-1,-1] cost [-1,-1,-1] -1 -1 -1 [] for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [] q = [[] for _ in range(4)] q [[] for _ in range(4)] for j in range(n):
    q[p[j]].append(l[j])
   j range(n) range n q[p[j]].append(l[j]) [p[j]].append [p[j]] q p[j] p j append l[j] l j for j in range(3):
    if len(q[j+1]) != 0:
      cost[j] = 10 * (len(q[j+1]) - 1) + abs(sum(q[j+1])-m[j])
   j range(3) range 3 if len(q[j+1]) != 0:
      cost[j] = 10 * (len(q[j+1]) - 1) + abs(sum(q[j+1])-m[j])
   len(q[j+1]) != 0 len(q[j+1]) len q[j+1] q j+1 j 1 0 cost[j] = 10 * (len(q[j+1]) - 1) + abs(sum(q[j+1])-m[j]) cost[j] cost j 10 * (len(q[j+1]) - 1) + abs(sum(q[j+1])-m[j]) 10 * (len(q[j+1]) - 1) 10 len(q[j+1]) - 1 len(q[j+1]) len q[j+1] q j+1 j 1 1 abs(sum(q[j+1])-m[j]) abs sum(q[j+1])-m[j] sum(q[j+1]) sum q[j+1] q j+1 j 1 m[j] m j if cost[0] != -1 and cost[1] != -1 and cost[2] != -1:
    ans = min(ans, cost[0] + cost[1] + cost[2]) cost[0] != -1 and cost[1] != -1 and cost[2] != -1 cost[0] != -1 and cost[1] != -1 cost[0] != -1 cost[0] cost 0 -1 cost[1] != -1 cost[1] cost 1 -1 cost[2] != -1 cost[2] cost 2 -1 ans = min(ans, cost[0] + cost[1] + cost[2]) ans min(ans, cost[0] + cost[1] + cost[2]) min ans cost[0] + cost[1] + cost[2] cost[0] + cost[1] cost[0] cost 0 cost[1] cost 1 cost[2] cost 2 print(ans) print ans n,a,b,c=map(int,input().split()) map(int,input().split()) n cost = [-1,-1,-1] [-1,-1,-1] cost ans = min(ans, cost[0] + cost[1] + cost[2]) min(ans, cost[0] + cost[1] + cost[2]) ans c=map(int,input().split()) map(int,input().split()) c q = [[] for _ in range(4)] [[] for _ in range(4)] q ans = 4000 4000 ans a,b,c=map(int,input().split()) map(int,input().split()) a k //= 4 4 k p = [0]*n [0]*n p k = i i k m = [a,b,c] [a,b,c] m b,c=map(int,input().split()) map(int,input().split()) b l = [] [] l
n,a,b,c=map(int,input().split())
l = []
for i in range(n):
  l.append(int(input()))
m = [a,b,c]
ans = 4000
for i in range(4**n):
  p = [0]*n
  k = i
  for j in range(n):
    p[j] = k % 4
    k //= 4
  cost = [-1,-1,-1]
  q = [[] for _ in range(4)]
  for j in range(n):
    q[p[j]].append(l[j])
  for j in range(3):
    if len(q[j+1]) != 0:
      cost[j] = 10 * (len(q[j+1]) - 1) + abs(sum(q[j+1])-m[j])
  if cost[0] != -1 and cost[1] != -1 and cost[2] != -1:
    ans = min(ans, cost[0] + cost[1] + cost[2])
print(ans)