from itertools import product
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
ans = INF

def calc(a, b, c):
    la, lb, lc = len(a), len(b), len(c)
    if la + lb + lc < 3 or 0 in (la, lb, lc): return INF
    sa, sb, sc = sum(a), sum(b), sum(c)
    t = 0
    return abs(sa-A) + abs(sb-B) + abs(sc-C) + (la+lb+lc-3) * 10

def dfs(n, a, b, c):
    global ans
    if n == N:
        ans = min(ans, calc(a, b, c))
        return
    dfs(n+1, a, b, c)
    dfs(n+1, a+[l[n]], b, c)
    dfs(n+1, a, b+[l[n]], c)
    dfs(n+1, a, b, c+[l[n]])

dfs(0, [], [], [])
print(ans) from itertools import product 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 = 10 ** 9 INF 10 ** 9 10 9 ans = INF ans INF def calc(a, b, c):
    la, lb, lc = len(a), len(b), len(c)
    if la + lb + lc < 3 or 0 in (la, lb, lc): return INF
    sa, sb, sc = sum(a), sum(b), sum(c)
    t = 0
    return abs(sa-A) + abs(sb-B) + abs(sc-C) + (la+lb+lc-3) * 10 calc la, lb, lc = len(a), len(b), len(c) la len(a) len a lb len(b) len b lc len(c) len c if la + lb + lc < 3 or 0 in (la, lb, lc): return INF
     la + lb + lc < 3 or 0 in (la, lb, lc) la + lb + lc < 3 la + lb + lc la + lb la lb lc 3 0 in (la, lb, lc) 0 (la, lb, lc) la lb lc sa, sb, sc = sum(a), sum(b), sum(c) sa sum(a) sum a sb sum(b) sum b sc sum(c) sum c t = 0 t 0 return abs(sa-A) + abs(sb-B) + abs(sc-C) + (la+lb+lc-3) * 10 abs(sa-A) + abs(sb-B) + abs(sc-C) + (la+lb+lc-3) * 10 abs(sa-A) + abs(sb-B) + abs(sc-C) abs(sa-A) + abs(sb-B) abs(sa-A) abs sa-A sa A abs(sb-B) abs sb-B sb B abs(sc-C) abs sc-C sc C (la+lb+lc-3) * 10 la+lb+lc-3 la+lb+lc la+lb la lb lc 3 10 a a b b c c def dfs(n, a, b, c):
    global ans
    if n == N:
        ans = min(ans, calc(a, b, c))
        return
    dfs(n+1, a, b, c)
    dfs(n+1, a+[l[n]], b, c)
    dfs(n+1, a, b+[l[n]], c)
    dfs(n+1, a, b, c+[l[n]]) dfs global ans if n == N:
        ans = min(ans, calc(a, b, c))
        return
     n == N n N ans = min(ans, calc(a, b, c)) ans min(ans, calc(a, b, c)) min ans calc(a, b, c) calc a b c return dfs(n+1, a, b, c) dfs n+1 n 1 a b c dfs(n+1, a+[l[n]], b, c) dfs n+1 n 1 a+[l[n]] a [l[n]] l[n] l n b c dfs(n+1, a, b+[l[n]], c) dfs n+1 n 1 a b+[l[n]] b [l[n]] l[n] l n c dfs(n+1, a, b, c+[l[n]]) dfs n+1 n 1 a b c+[l[n]] c [l[n]] l[n] l n n n a a b b c c dfs(0, [], [], []) dfs 0 [] [] [] print(ans) print ans INF = 10 ** 9 10 ** 9 INF l = [int(input()) for i in range(N)] [int(input()) for i in range(N)] l C = map(int, input().split()) map(int, input().split()) C ans = INF INF ans B, C = map(int, input().split()) map(int, input().split()) B A, B, C = map(int, input().split()) map(int, input().split()) A def calc(a, b, c):
    la, lb, lc = len(a), len(b), len(c)
    if la + lb + lc < 3 or 0 in (la, lb, lc): return INF
    sa, sb, sc = sum(a), sum(b), sum(c)
    t = 0
    return abs(sa-A) + abs(sb-B) + abs(sc-C) + (la+lb+lc-3) * 10 def calc(a, b, c):
    la, lb, lc = len(a), len(b), len(c)
    if la + lb + lc < 3 or 0 in (la, lb, lc): return INF
    sa, sb, sc = sum(a), sum(b), sum(c)
    t = 0
    return abs(sa-A) + abs(sb-B) + abs(sc-C) + (la+lb+lc-3) * 10 calc N, A, B, C = map(int, input().split()) map(int, input().split()) N def dfs(n, a, b, c):
    global ans
    if n == N:
        ans = min(ans, calc(a, b, c))
        return
    dfs(n+1, a, b, c)
    dfs(n+1, a+[l[n]], b, c)
    dfs(n+1, a, b+[l[n]], c)
    dfs(n+1, a, b, c+[l[n]]) def dfs(n, a, b, c):
    global ans
    if n == N:
        ans = min(ans, calc(a, b, c))
        return
    dfs(n+1, a, b, c)
    dfs(n+1, a+[l[n]], b, c)
    dfs(n+1, a, b+[l[n]], c)
    dfs(n+1, a, b, c+[l[n]]) dfs
from itertools import product
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
ans = INF

def calc(a, b, c):
    la, lb, lc = len(a), len(b), len(c)
    if la + lb + lc < 3 or 0 in (la, lb, lc): return INF
    sa, sb, sc = sum(a), sum(b), sum(c)
    t = 0
    return abs(sa-A) + abs(sb-B) + abs(sc-C) + (la+lb+lc-3) * 10

def dfs(n, a, b, c):
    global ans
    if n == N:
        ans = min(ans, calc(a, b, c))
        return
    dfs(n+1, a, b, c)
    dfs(n+1, a+[l[n]], b, c)
    dfs(n+1, a, b+[l[n]], c)
    dfs(n+1, a, b, c+[l[n]])

dfs(0, [], [], [])
print(ans)
