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

def rec(i, a, b, c):
  if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
  ret = rec(i+1, a, b, c)
  
  ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0))
  ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0))
  ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0))
  
  return ret

print(rec(0, 0, 0, 0)) 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 _ in range(N):
  L.append(int(input())) _ range(N) range N L.append(int(input())) L.append L append int(input()) int input() input def rec(i, a, b, c):
  if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
  ret = rec(i+1, a, b, c)
  
  ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0))
  ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0))
  ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0))
  
  return ret rec if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
   i == N i N if not a or not b or not c: return float('inf')
     not a or not b or not c not a or not b not a a not b b not c c return abs(a-A) + abs(b-B) + abs(c-C) abs(a-A) + abs(b-B) + abs(c-C) abs(a-A) + abs(b-B) abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C ret = rec(i+1, a, b, c) ret rec(i+1, a, b, c) rec i+1 i 1 a b c ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0)) ret min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0)) min ret rec(i+1, a+L[i], b, c) + (10 if a else 0) rec(i+1, a+L[i], b, c) rec i+1 i 1 a+L[i] a L[i] L i b c 10 if a else 0 a 10 0 ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0)) ret min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0)) min ret rec(i+1, a, b+L[i], c) + (10 if b else 0) rec(i+1, a, b+L[i], c) rec i+1 i 1 a b+L[i] b L[i] L i c 10 if b else 0 b 10 0 ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0)) ret min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0)) min ret rec(i+1, a, b, c+L[i]) + (10 if c else 0) rec(i+1, a, b, c+L[i]) rec i+1 i 1 a b c+L[i] c L[i] L i 10 if c else 0 c 10 0 return ret ret i i a a b b c c print(rec(0, 0, 0, 0)) print rec(0, 0, 0, 0) rec 0 0 0 0 N, A, B, C = map(int, input().split()) map(int, input().split()) N C = map(int, input().split()) map(int, input().split()) C B, C = map(int, input().split()) map(int, input().split()) B def rec(i, a, b, c):
  if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
  ret = rec(i+1, a, b, c)
  
  ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0))
  ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0))
  ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0))
  
  return ret def rec(i, a, b, c):
  if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
  ret = rec(i+1, a, b, c)
  
  ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0))
  ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0))
  ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0))
  
  return ret rec L = [] [] L A, B, C = map(int, input().split()) map(int, input().split()) A
N, A, B, C = map(int, input().split())
L = []
for _ in range(N):
  L.append(int(input()))

def rec(i, a, b, c):
  if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
  ret = rec(i+1, a, b, c)
  
  ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0))
  ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0))
  ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0))
  
  return ret

print(rec(0, 0, 0, 0))
