N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
 
INF = float('inf')
ans = INF
 
def dfs(a, b, c, n, cost):
    global ans
    if n == N:
        cost += abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
        ans = min(ans, cost)
        return
    dfs(a, b, c, n+1, cost)
    dfs(a+l[n], b, c, n+1, cost+10)
    dfs(a, b+l[n], c, n+1, cost+10)
    dfs(a, b, c+l[n], n+1, cost+10)
 
dfs(0, 0, 0, 0, 0)
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 i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input l = [int(input()) for i in range(N)] l [int(input()) for i in range(N)] INF = float('inf') INF float('inf') float 'inf' ans = INF ans INF def dfs(a, b, c, n, cost):
    global ans
    if n == N:
        cost += abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
        ans = min(ans, cost)
        return
    dfs(a, b, c, n+1, cost)
    dfs(a+l[n], b, c, n+1, cost+10)
    dfs(a, b+l[n], c, n+1, cost+10)
    dfs(a, b, c+l[n], n+1, cost+10)
  dfs global ans if n == N:
        cost += abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
        ans = min(ans, cost)
        return
     n == N n N cost += abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF cost abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF min(a, b, c) > 0 min(a, b, c) min a b c 0 abs(A - a) + abs(B - b) + abs(C - c) - 30 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 30 INF ans = min(ans, cost) ans min(ans, cost) min ans cost return dfs(a, b, c, n+1, cost) dfs a b c n+1 n 1 cost dfs(a+l[n], b, c, n+1, cost+10) dfs a+l[n] a l[n] l n b c n+1 n 1 cost+10 cost 10 dfs(a, b+l[n], c, n+1, cost+10) dfs a b+l[n] b l[n] l n c n+1 n 1 cost+10 cost 10 dfs(a, b, c+l[n], n+1, cost+10) dfs a b c+l[n] c l[n] l n n+1 n 1 cost+10 cost 10 a a b b c c n n cost cost dfs(0, 0, 0, 0, 0) dfs 0 0 0 0 0 print(ans) print ans def dfs(a, b, c, n, cost):
    global ans
    if n == N:
        cost += abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
        ans = min(ans, cost)
        return
    dfs(a, b, c, n+1, cost)
    dfs(a+l[n], b, c, n+1, cost+10)
    dfs(a, b+l[n], c, n+1, cost+10)
    dfs(a, b, c+l[n], n+1, cost+10)
  def dfs(a, b, c, n, cost):
    global ans
    if n == N:
        cost += abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
        ans = min(ans, cost)
        return
    dfs(a, b, c, n+1, cost)
    dfs(a+l[n], b, c, n+1, cost+10)
    dfs(a, b+l[n], c, n+1, cost+10)
    dfs(a, b, c+l[n], n+1, cost+10)
  dfs A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C B, C = map(int, input().split()) map(int, input().split()) B N, A, B, C = map(int, input().split()) map(int, input().split()) N ans = INF INF ans INF = float('inf') float('inf') INF l = [int(input()) for i in range(N)] [int(input()) for i in range(N)] l
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
 
INF = float('inf')
ans = INF
 
def dfs(a, b, c, n, cost):
    global ans
    if n == N:
        cost += abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
        ans = min(ans, cost)
        return
    dfs(a, b, c, n+1, cost)
    dfs(a+l[n], b, c, n+1, cost+10)
    dfs(a, b+l[n], c, n+1, cost+10)
    dfs(a, b, c+l[n], n+1, cost+10)
 
dfs(0, 0, 0, 0, 0)
print(ans)
