N, A, B, C = map(int, input().split())
X = [0, A, B, C]
L = [int(input()) for _ in range(N)]
d = 4 ** N
magic = int(1e+9)
for i in range(d):
  F = [0 for _ in range(4)]
  cnt = [0 for _ in range(4)]
  tmp = i
  for j in range(N):
    F[i%4] += L[j]
    cnt[i%4] += 1
    i //= 4
  p = True
  for k in range(1, 4):
    if F[k] == 0:
      p = False
      break
  tmpp = 0
  if p:
    for k in range(1, 4):
      tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10
    if tmpp < magic:
      magic = tmpp
print(magic) N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C X = [0, A, B, C] X [0, A, B, C] 0 A B C int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input L = [int(input()) for _ in range(N)] L [int(input()) for _ in range(N)] d = 4 ** N d 4 ** N 4 N magic = int(1e+9) magic int(1e+9) int 1e+9 for i in range(d):
  F = [0 for _ in range(4)]
  cnt = [0 for _ in range(4)]
  tmp = i
  for j in range(N):
    F[i%4] += L[j]
    cnt[i%4] += 1
    i //= 4
  p = True
  for k in range(1, 4):
    if F[k] == 0:
      p = False
      break
  tmpp = 0
  if p:
    for k in range(1, 4):
      tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10
    if tmpp < magic:
      magic = tmpp i range(d) range d 0 for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) 0 F = [0 for _ in range(4)] F [0 for _ in range(4)] 0 for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) 0 cnt = [0 for _ in range(4)] cnt [0 for _ in range(4)] tmp = i tmp i for j in range(N):
    F[i%4] += L[j]
    cnt[i%4] += 1
    i //= 4
   j range(N) range N F[i%4] += L[j] F[i%4] F i%4 i 4 L[j] L j cnt[i%4] += 1 cnt[i%4] cnt i%4 i 4 1 i //= 4 i 4 p = True p True for k in range(1, 4):
    if F[k] == 0:
      p = False
      break
   k range(1, 4) range 1 4 if F[k] == 0:
      p = False
      break
   F[k] == 0 F[k] F k 0 p = False p False break tmpp = 0 tmpp 0 if p:
    for k in range(1, 4):
      tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10
    if tmpp < magic:
      magic = tmpp p for k in range(1, 4):
      tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10
     k range(1, 4) range 1 4 tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10 tmpp cnt[k] * 10 + abs(X[k] - F[k]) - 10 cnt[k] * 10 + abs(X[k] - F[k]) cnt[k] * 10 cnt[k] cnt k 10 abs(X[k] - F[k]) abs X[k] - F[k] X[k] X k F[k] F k 10 if tmpp < magic:
      magic = tmpp tmpp < magic tmpp magic magic = tmpp magic tmpp print(magic) print magic tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10 cnt[k] * 10 + abs(X[k] - F[k]) - 10 tmpp p = False False p L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L B, C = map(int, input().split()) map(int, input().split()) B magic = tmpp tmpp magic X = [0, A, B, C] [0, A, B, C] X tmpp = 0 0 tmpp cnt = [0 for _ in range(4)] [0 for _ in range(4)] cnt i //= 4 4 i p = True True p C = map(int, input().split()) map(int, input().split()) C F = [0 for _ in range(4)] [0 for _ in range(4)] F N, A, B, C = map(int, input().split()) map(int, input().split()) N tmp = i i tmp d = 4 ** N 4 ** N d A, B, C = map(int, input().split()) map(int, input().split()) A magic = int(1e+9) int(1e+9) magic
N, A, B, C = map(int, input().split())
X = [0, A, B, C]
L = [int(input()) for _ in range(N)]
d = 4 ** N
magic = int(1e+9)
for i in range(d):
  F = [0 for _ in range(4)]
  cnt = [0 for _ in range(4)]
  tmp = i
  for j in range(N):
    F[i%4] += L[j]
    cnt[i%4] += 1
    i //= 4
  p = True
  for k in range(1, 4):
    if F[k] == 0:
      p = False
      break
  tmpp = 0
  if p:
    for k in range(1, 4):
      tmpp += cnt[k] * 10 + abs(X[k] - F[k]) - 10
    if tmpp < magic:
      magic = tmpp
print(magic)