import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def build(l, A):
    # minimum cost for mask to A
    N = len(l)
    mask_to_cost = [math.inf]*(1<<N)
    for m in range(1, 1<<N):
        i = 0
        cost = 0
        length = 0
        while i < N:
            if m&(1<<i):
                cost += 10
                length += l[N-i-1]
            i += 1
        if cost > 0:
            cost -= 10
        cost += abs(length-A)
        mask_to_cost[m] = cost
    for m in range(1<<N):
        s = m
        while s > 0:
            s = (s-1)&m
            mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s])
    return mask_to_cost


def solve():
    N, A, B, C = read_ints()
    l = [read_int() for _ in range(N)]
    A_cost = build(l, A)
    B_cost = build(l, B)
    C_cost = build(l, C)
    min_cost = math.inf
    for a_mask in range(1, 1<<N):
        bc_mask = ((1<<N)-1)-a_mask
        b_mask = bc_mask
        while b_mask > 0:
            b_mask = (b_mask-1)&bc_mask
            c_mask = bc_mask-b_mask
            if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
    return min_cost


if __name__ == '__main__':
    print(solve()) import math math def read_int():
    return int(input().strip()) read_int return int(input().strip()) int(input().strip()) int input().strip() ().strip () input strip def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints return list(map(int, input().strip().split(' '))) list(map(int, input().strip().split(' '))) list map(int, input().strip().split(' ')) map int input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' def build(l, A):
    # minimum cost for mask to A
    N = len(l)
    mask_to_cost = [math.inf]*(1<<N)
    for m in range(1, 1<<N):
        i = 0
        cost = 0
        length = 0
        while i < N:
            if m&(1<<i):
                cost += 10
                length += l[N-i-1]
            i += 1
        if cost > 0:
            cost -= 10
        cost += abs(length-A)
        mask_to_cost[m] = cost
    for m in range(1<<N):
        s = m
        while s > 0:
            s = (s-1)&m
            mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s])
    return mask_to_cost build N = len(l) N len(l) len l mask_to_cost = [math.inf]*(1<<N) mask_to_cost [math.inf]*(1<<N) [math.inf] math.inf math inf 1<<N 1 N for m in range(1, 1<<N):
        i = 0
        cost = 0
        length = 0
        while i < N:
            if m&(1<<i):
                cost += 10
                length += l[N-i-1]
            i += 1
        if cost > 0:
            cost -= 10
        cost += abs(length-A)
        mask_to_cost[m] = cost
     m range(1, 1<<N) range 1 1<<N 1 N i = 0 i 0 cost = 0 cost 0 length = 0 length 0 while i < N:
            if m&(1<<i):
                cost += 10
                length += l[N-i-1]
            i += 1
         i < N i N if m&(1<<i):
                cost += 10
                length += l[N-i-1]
             m&(1<<i) m 1<<i 1 i cost += 10 cost 10 length += l[N-i-1] length l[N-i-1] l N-i-1 N-i N i 1 i += 1 i 1 if cost > 0:
            cost -= 10
         cost > 0 cost 0 cost -= 10 cost 10 cost += abs(length-A) cost abs(length-A) abs length-A length A mask_to_cost[m] = cost mask_to_cost[m] mask_to_cost m cost for m in range(1<<N):
        s = m
        while s > 0:
            s = (s-1)&m
            mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s])
     m range(1<<N) range 1<<N 1 N s = m s m while s > 0:
            s = (s-1)&m
            mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s])
     s > 0 s 0 s = (s-1)&m s (s-1)&m s-1 s 1 m mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s]) mask_to_cost[m] mask_to_cost m min(mask_to_cost[m], mask_to_cost[s]) min mask_to_cost[m] mask_to_cost m mask_to_cost[s] mask_to_cost s return mask_to_cost mask_to_cost l l A A def solve():
    N, A, B, C = read_ints()
    l = [read_int() for _ in range(N)]
    A_cost = build(l, A)
    B_cost = build(l, B)
    C_cost = build(l, C)
    min_cost = math.inf
    for a_mask in range(1, 1<<N):
        bc_mask = ((1<<N)-1)-a_mask
        b_mask = bc_mask
        while b_mask > 0:
            b_mask = (b_mask-1)&bc_mask
            c_mask = bc_mask-b_mask
            if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
    return min_cost solve N, A, B, C = read_ints() N read_ints() read_ints A B C read_int() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) read_int() read_int l = [read_int() for _ in range(N)] l [read_int() for _ in range(N)] A_cost = build(l, A) A_cost build(l, A) build l A B_cost = build(l, B) B_cost build(l, B) build l B C_cost = build(l, C) C_cost build(l, C) build l C min_cost = math.inf min_cost math.inf math inf for a_mask in range(1, 1<<N):
        bc_mask = ((1<<N)-1)-a_mask
        b_mask = bc_mask
        while b_mask > 0:
            b_mask = (b_mask-1)&bc_mask
            c_mask = bc_mask-b_mask
            if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
     a_mask range(1, 1<<N) range 1 1<<N 1 N bc_mask = ((1<<N)-1)-a_mask bc_mask ((1<<N)-1)-a_mask (1<<N)-1 1<<N 1 N 1 a_mask b_mask = bc_mask b_mask bc_mask while b_mask > 0:
            b_mask = (b_mask-1)&bc_mask
            c_mask = bc_mask-b_mask
            if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
     b_mask > 0 b_mask 0 b_mask = (b_mask-1)&bc_mask b_mask (b_mask-1)&bc_mask b_mask-1 b_mask 1 bc_mask c_mask = bc_mask-b_mask c_mask bc_mask-b_mask bc_mask b_mask if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
     b_mask and c_mask b_mask c_mask min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask]) min_cost min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask]) min min_cost A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask] A_cost[a_mask]+B_cost[b_mask] A_cost[a_mask] A_cost a_mask B_cost[b_mask] B_cost b_mask C_cost[c_mask] C_cost c_mask return min_cost min_cost if __name__ == '__main__':
    print(solve()) __name__ == '__main__' __name__ '__main__' print(solve()) print solve() solve def read_ints():
    return list(map(int, input().strip().split(' '))) def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints def build(l, A):
    # minimum cost for mask to A
    N = len(l)
    mask_to_cost = [math.inf]*(1<<N)
    for m in range(1, 1<<N):
        i = 0
        cost = 0
        length = 0
        while i < N:
            if m&(1<<i):
                cost += 10
                length += l[N-i-1]
            i += 1
        if cost > 0:
            cost -= 10
        cost += abs(length-A)
        mask_to_cost[m] = cost
    for m in range(1<<N):
        s = m
        while s > 0:
            s = (s-1)&m
            mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s])
    return mask_to_cost def build(l, A):
    # minimum cost for mask to A
    N = len(l)
    mask_to_cost = [math.inf]*(1<<N)
    for m in range(1, 1<<N):
        i = 0
        cost = 0
        length = 0
        while i < N:
            if m&(1<<i):
                cost += 10
                length += l[N-i-1]
            i += 1
        if cost > 0:
            cost -= 10
        cost += abs(length-A)
        mask_to_cost[m] = cost
    for m in range(1<<N):
        s = m
        while s > 0:
            s = (s-1)&m
            mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s])
    return mask_to_cost build def solve():
    N, A, B, C = read_ints()
    l = [read_int() for _ in range(N)]
    A_cost = build(l, A)
    B_cost = build(l, B)
    C_cost = build(l, C)
    min_cost = math.inf
    for a_mask in range(1, 1<<N):
        bc_mask = ((1<<N)-1)-a_mask
        b_mask = bc_mask
        while b_mask > 0:
            b_mask = (b_mask-1)&bc_mask
            c_mask = bc_mask-b_mask
            if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
    return min_cost def solve():
    N, A, B, C = read_ints()
    l = [read_int() for _ in range(N)]
    A_cost = build(l, A)
    B_cost = build(l, B)
    C_cost = build(l, C)
    min_cost = math.inf
    for a_mask in range(1, 1<<N):
        bc_mask = ((1<<N)-1)-a_mask
        b_mask = bc_mask
        while b_mask > 0:
            b_mask = (b_mask-1)&bc_mask
            c_mask = bc_mask-b_mask
            if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
    return min_cost solve def read_int():
    return int(input().strip()) def read_int():
    return int(input().strip()) read_int
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def build(l, A):
    # minimum cost for mask to A
    N = len(l)
    mask_to_cost = [math.inf]*(1<<N)
    for m in range(1, 1<<N):
        i = 0
        cost = 0
        length = 0
        while i < N:
            if m&(1<<i):
                cost += 10
                length += l[N-i-1]
            i += 1
        if cost > 0:
            cost -= 10
        cost += abs(length-A)
        mask_to_cost[m] = cost
    for m in range(1<<N):
        s = m
        while s > 0:
            s = (s-1)&m
            mask_to_cost[m] = min(mask_to_cost[m], mask_to_cost[s])
    return mask_to_cost


def solve():
    N, A, B, C = read_ints()
    l = [read_int() for _ in range(N)]
    A_cost = build(l, A)
    B_cost = build(l, B)
    C_cost = build(l, C)
    min_cost = math.inf
    for a_mask in range(1, 1<<N):
        bc_mask = ((1<<N)-1)-a_mask
        b_mask = bc_mask
        while b_mask > 0:
            b_mask = (b_mask-1)&bc_mask
            c_mask = bc_mask-b_mask
            if b_mask and c_mask:
                min_cost = min(min_cost, A_cost[a_mask]+B_cost[b_mask]+C_cost[c_mask])
    return min_cost


if __name__ == '__main__':
    print(solve())
