from itertools import product

N, *ABC = map(int, input().split())

L = []
for _ in range(N):
  L.append(int(input()))

ans = 10**9
for X in product((0, 1, 2, 3), repeat=N):
  cnt, K, temp = [0]*4, [0]*4, 0
  for i in range(N):
    cnt[X[i]] += 1
    K[X[i]] += L[i]
  if min(cnt[1:]) == 0:
    continue
  for i in range(3):
    temp += abs(ABC[i] - K[i+1])
    temp += 10 * max(cnt[i+1]-1, 0)
  ans = min(ans, temp)

print(ans) from itertools import product N, *ABC = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split *ABC ABC 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 ans = 10**9 ans 10**9 10 9 for X in product((0, 1, 2, 3), repeat=N):
  cnt, K, temp = [0]*4, [0]*4, 0
  for i in range(N):
    cnt[X[i]] += 1
    K[X[i]] += L[i]
  if min(cnt[1:]) == 0:
    continue
  for i in range(3):
    temp += abs(ABC[i] - K[i+1])
    temp += 10 * max(cnt[i+1]-1, 0)
  ans = min(ans, temp) X product((0, 1, 2, 3), repeat=N) product (0, 1, 2, 3) 0 1 2 3 repeat=N repeat N cnt, K, temp = [0]*4, [0]*4, 0 cnt [0]*4 [0] 0 4 K [0]*4 [0] 0 4 temp 0 for i in range(N):
    cnt[X[i]] += 1
    K[X[i]] += L[i]
   i range(N) range N cnt[X[i]] += 1 cnt[X[i]] cnt X[i] X i 1 K[X[i]] += L[i] K[X[i]] K X[i] X i L[i] L i if min(cnt[1:]) == 0:
    continue
   min(cnt[1:]) == 0 min(cnt[1:]) min cnt[1:] cnt 1: 1 0 continue for i in range(3):
    temp += abs(ABC[i] - K[i+1])
    temp += 10 * max(cnt[i+1]-1, 0)
   i range(3) range 3 temp += abs(ABC[i] - K[i+1]) temp abs(ABC[i] - K[i+1]) abs ABC[i] - K[i+1] ABC[i] ABC i K[i+1] K i+1 i 1 temp += 10 * max(cnt[i+1]-1, 0) temp 10 * max(cnt[i+1]-1, 0) 10 max(cnt[i+1]-1, 0) max cnt[i+1]-1 cnt[i+1] cnt i+1 i 1 1 0 ans = min(ans, temp) ans min(ans, temp) min ans temp print(ans) print ans ans = 10**9 10**9 ans K, temp = [0]*4, [0]*4, 0 [0]*4 K L = [] [] L temp += 10 * max(cnt[i+1]-1, 0) 10 * max(cnt[i+1]-1, 0) temp N, *ABC = map(int, input().split()) map(int, input().split()) N temp = [0]*4, [0]*4, 0 0 temp temp += abs(ABC[i] - K[i+1]) abs(ABC[i] - K[i+1]) temp ans = min(ans, temp) min(ans, temp) ans cnt, K, temp = [0]*4, [0]*4, 0 [0]*4 cnt
from itertools import product

N, *ABC = map(int, input().split())

L = []
for _ in range(N):
  L.append(int(input()))

ans = 10**9
for X in product((0, 1, 2, 3), repeat=N):
  cnt, K, temp = [0]*4, [0]*4, 0
  for i in range(N):
    cnt[X[i]] += 1
    K[X[i]] += L[i]
  if min(cnt[1:]) == 0:
    continue
  for i in range(3):
    temp += abs(ABC[i] - K[i+1])
    temp += 10 * max(cnt[i+1]-1, 0)
  ans = min(ans, temp)

print(ans)