n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
ans =  10**6
for i in range(4**n):
  s = Base_10_to_n(i, 4)
  s = s.zfill(n)
  l_temp = [0, 0, 0]
  cnt = [0, 0, 0]
  for num, j in enumerate(s):
    if int(j):
      l_temp[int(j)-1] += l[num]
      cnt[int(j)-1] += 1
  if 0 in cnt:
    continue
  else:
    ans_temp = 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2])
    ans = min(ans, ans_temp) 
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 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)] def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out Base_10_to_n X_dumy = X X_dumy X out = '' out '' while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
     X_dumy>0 X_dumy 0 out = str(X_dumy%n)+out out str(X_dumy%n)+out str(X_dumy%n) str X_dumy%n X_dumy n out X_dumy = int(X_dumy/n) X_dumy int(X_dumy/n) int X_dumy/n X_dumy n return out out X X n n ans =  10**6 ans 10**6 10 6 for i in range(4**n):
  s = Base_10_to_n(i, 4)
  s = s.zfill(n)
  l_temp = [0, 0, 0]
  cnt = [0, 0, 0]
  for num, j in enumerate(s):
    if int(j):
      l_temp[int(j)-1] += l[num]
      cnt[int(j)-1] += 1
  if 0 in cnt:
    continue
  else:
    ans_temp = 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2])
    ans = min(ans, ans_temp)  i range(4**n) range 4**n 4 n s = Base_10_to_n(i, 4) s Base_10_to_n(i, 4) Base_10_to_n i 4 s = s.zfill(n) s s.zfill(n) s.zfill s zfill n l_temp = [0, 0, 0] l_temp [0, 0, 0] 0 0 0 cnt = [0, 0, 0] cnt [0, 0, 0] 0 0 0 for num, j in enumerate(s):
    if int(j):
      l_temp[int(j)-1] += l[num]
      cnt[int(j)-1] += 1
   num j enumerate(s) enumerate s if int(j):
      l_temp[int(j)-1] += l[num]
      cnt[int(j)-1] += 1
   int(j) int j l_temp[int(j)-1] += l[num] l_temp[int(j)-1] l_temp int(j)-1 int(j) int j 1 l[num] l num cnt[int(j)-1] += 1 cnt[int(j)-1] cnt int(j)-1 int(j) int j 1 1 if 0 in cnt:
    continue
  else:
    ans_temp = 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2])
    ans = min(ans, ans_temp)  0 in cnt 0 cnt continue ans_temp = 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2]) ans_temp 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2]) 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) 10*(sum(cnt)-3) +abs(A-l_temp[0]) 10*(sum(cnt)-3) 10 sum(cnt)-3 sum(cnt) sum cnt 3 abs(A-l_temp[0]) abs A-l_temp[0] A l_temp[0] l_temp 0 abs(B-l_temp[1]) abs B-l_temp[1] B l_temp[1] l_temp 1 abs(C-l_temp[2]) abs C-l_temp[2] C l_temp[2] l_temp 2 ans = min(ans, ans_temp) ans min(ans, ans_temp) min ans ans_temp print(ans) print ans ans = min(ans, ans_temp) min(ans, ans_temp) ans l_temp = [0, 0, 0] [0, 0, 0] l_temp B, C = map(int, input().split()) map(int, input().split()) B ans_temp = 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2]) 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2]) ans_temp ans =  10**6 10**6 ans s = s.zfill(n) s.zfill(n) s s = Base_10_to_n(i, 4) Base_10_to_n(i, 4) s n, A, B, C = map(int, input().split()) map(int, input().split()) n A, B, C = map(int, input().split()) map(int, input().split()) A l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out Base_10_to_n C = map(int, input().split()) map(int, input().split()) C cnt = [0, 0, 0] [0, 0, 0] cnt
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
ans =  10**6
for i in range(4**n):
  s = Base_10_to_n(i, 4)
  s = s.zfill(n)
  l_temp = [0, 0, 0]
  cnt = [0, 0, 0]
  for num, j in enumerate(s):
    if int(j):
      l_temp[int(j)-1] += l[num]
      cnt[int(j)-1] += 1
  if 0 in cnt:
    continue
  else:
    ans_temp = 10*(sum(cnt)-3) +abs(A-l_temp[0]) + abs(B-l_temp[1]) + abs(C-l_temp[2])
    ans = min(ans, ans_temp) 
print(ans)