n, a, b, c = map(int, input().split())
bamboo = [0]*n
for i in range(n):
  bamboo[i] = int(input())

answer = 10**10
for i in range(4**n):
  key = [0, 0, 0, 0]
  sub = [0, 0, 0]
  for j in range(n):
    k = 0
    if (i >> (2*j))&1:
      k += 1
    if (i >> (2*j+1))&1:
      k += 2
    key[k] += 1
    if k != 3:
      sub[k] += bamboo[j]
  if not all(sub):
    continue
  ans = (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b)+abs(sub[2]-c)
  if ans < answer:
    answer = ans
print(answer)  n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c bamboo = [0]*n bamboo [0]*n [0] 0 n for i in range(n):
  bamboo[i] = int(input()) i range(n) range n bamboo[i] = int(input()) bamboo[i] bamboo i int(input()) int input() input answer = 10**10 answer 10**10 10 10 for i in range(4**n):
  key = [0, 0, 0, 0]
  sub = [0, 0, 0]
  for j in range(n):
    k = 0
    if (i >> (2*j))&1:
      k += 1
    if (i >> (2*j+1))&1:
      k += 2
    key[k] += 1
    if k != 3:
      sub[k] += bamboo[j]
  if not all(sub):
    continue
  ans = (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b)+abs(sub[2]-c)
  if ans < answer:
    answer = ans i range(4**n) range 4**n 4 n key = [0, 0, 0, 0] key [0, 0, 0, 0] 0 0 0 0 sub = [0, 0, 0] sub [0, 0, 0] 0 0 0 for j in range(n):
    k = 0
    if (i >> (2*j))&1:
      k += 1
    if (i >> (2*j+1))&1:
      k += 2
    key[k] += 1
    if k != 3:
      sub[k] += bamboo[j]
   j range(n) range n k = 0 k 0 if (i >> (2*j))&1:
      k += 1
     (i >> (2*j))&1 i >> (2*j) i 2*j 2 j 1 k += 1 k 1 if (i >> (2*j+1))&1:
      k += 2
     (i >> (2*j+1))&1 i >> (2*j+1) i 2*j+1 2*j 2 j 1 1 k += 2 k 2 key[k] += 1 key[k] key k 1 if k != 3:
      sub[k] += bamboo[j]
   k != 3 k 3 sub[k] += bamboo[j] sub[k] sub k bamboo[j] bamboo j if not all(sub):
    continue
   not all(sub) all(sub) all sub continue ans = (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b)+abs(sub[2]-c) ans (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b)+abs(sub[2]-c) (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b) (sum(key[:3])-3)*10+abs(sub[0]-a) (sum(key[:3])-3)*10 sum(key[:3])-3 sum(key[:3]) sum key[:3] key :3 3 3 10 abs(sub[0]-a) abs sub[0]-a sub[0] sub 0 a abs(sub[1]-b) abs sub[1]-b sub[1] sub 1 b abs(sub[2]-c) abs sub[2]-c sub[2] sub 2 c if ans < answer:
    answer = ans ans < answer ans answer answer = ans answer ans print(answer) print answer k += 2 2 k b, c = map(int, input().split()) map(int, input().split()) b a, b, c = map(int, input().split()) map(int, input().split()) a c = map(int, input().split()) map(int, input().split()) c sub = [0, 0, 0] [0, 0, 0] sub answer = ans ans answer k = 0 0 k key = [0, 0, 0, 0] [0, 0, 0, 0] key ans = (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b)+abs(sub[2]-c) (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b)+abs(sub[2]-c) ans n, a, b, c = map(int, input().split()) map(int, input().split()) n k += 1 1 k answer = 10**10 10**10 answer bamboo = [0]*n [0]*n bamboo
n, a, b, c = map(int, input().split())
bamboo = [0]*n
for i in range(n):
  bamboo[i] = int(input())

answer = 10**10
for i in range(4**n):
  key = [0, 0, 0, 0]
  sub = [0, 0, 0]
  for j in range(n):
    k = 0
    if (i >> (2*j))&1:
      k += 1
    if (i >> (2*j+1))&1:
      k += 2
    key[k] += 1
    if k != 3:
      sub[k] += bamboo[j]
  if not all(sub):
    continue
  ans = (sum(key[:3])-3)*10+abs(sub[0]-a)+abs(sub[1]-b)+abs(sub[2]-c)
  if ans < answer:
    answer = ans
print(answer) 