n, *abc = [int(x) for x in input().split()]
l = [int(input()) for i in range(n)]
A = 0; B = 1; C = 2;

minmp = 10 ** 9
for k in range(2 ** (2 * n)):
    mat = [[], [], [], []]  # mat[0]:= Aの材料, mat[1]:=Bの材料, mat[2]:=Cの材料
    # for i = 0, ..., N-1
    # kの 2*i & 2*i+1ビット目が 0b00: l[i]はAに使う
    #     ↑lsbから             0b01: l[i]はBに使う
    #                         0b10: l[i]はCに使う
    #                         0b11: l[i]は使わない
    for i in range(n):
        mat[k & (0b11)].append(l[i])
        k >>= 2

    if len(mat[0]) == 0 or len(mat[1]) == 0 or len(mat[2]) == 0:
        continue

    mp = 0
    for j in range(3):
        mp += 10 * (len(mat[j]) - 1)
        mp += 1 * abs(abc[j] - sum(mat[j]))

    minmp = min(minmp, mp)

print(minmp) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n, *abc = [int(x) for x in input().split()] n [int(x) for x in input().split()] *abc abc 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)] A = 0 A 0 B = 1 B 1 C = 2 C 2 minmp = 10 ** 9 minmp 10 ** 9 10 9 for k in range(2 ** (2 * n)):
    mat = [[], [], [], []]  # mat[0]:= Aの材料, mat[1]:=Bの材料, mat[2]:=Cの材料
    # for i = 0, ..., N-1
    # kの 2*i & 2*i+1ビット目が 0b00: l[i]はAに使う
    #     ↑lsbから             0b01: l[i]はBに使う
    #                         0b10: l[i]はCに使う
    #                         0b11: l[i]は使わない
    for i in range(n):
        mat[k & (0b11)].append(l[i])
        k >>= 2

    if len(mat[0]) == 0 or len(mat[1]) == 0 or len(mat[2]) == 0:
        continue

    mp = 0
    for j in range(3):
        mp += 10 * (len(mat[j]) - 1)
        mp += 1 * abs(abc[j] - sum(mat[j]))

    minmp = min(minmp, mp) k range(2 ** (2 * n)) range 2 ** (2 * n) 2 2 * n 2 n mat = [[], [], [], []] mat [[], [], [], []] [] [] [] [] for i in range(n):
        mat[k & (0b11)].append(l[i])
        k >>= 2

     i range(n) range n mat[k & (0b11)].append(l[i]) [k & (0b11)].append [k & (0b11)] mat k & (0b11) k 0b11 append l[i] l i k >>= 2 k 2 if len(mat[0]) == 0 or len(mat[1]) == 0 or len(mat[2]) == 0:
        continue

     len(mat[0]) == 0 or len(mat[1]) == 0 or len(mat[2]) == 0 len(mat[0]) == 0 or len(mat[1]) == 0 len(mat[0]) == 0 len(mat[0]) len mat[0] mat 0 0 len(mat[1]) == 0 len(mat[1]) len mat[1] mat 1 0 len(mat[2]) == 0 len(mat[2]) len mat[2] mat 2 0 continue mp = 0 mp 0 for j in range(3):
        mp += 10 * (len(mat[j]) - 1)
        mp += 1 * abs(abc[j] - sum(mat[j]))

     j range(3) range 3 mp += 10 * (len(mat[j]) - 1) mp 10 * (len(mat[j]) - 1) 10 len(mat[j]) - 1 len(mat[j]) len mat[j] mat j 1 mp += 1 * abs(abc[j] - sum(mat[j])) mp 1 * abs(abc[j] - sum(mat[j])) 1 abs(abc[j] - sum(mat[j])) abs abc[j] - sum(mat[j]) abc[j] abc j sum(mat[j]) sum mat[j] mat j minmp = min(minmp, mp) minmp min(minmp, mp) min minmp mp print(minmp) print minmp B = 1 1 B C = 2 2 C k >>= 2 2 k minmp = 10 ** 9 10 ** 9 minmp n, *abc = [int(x) for x in input().split()] [int(x) for x in input().split()] n l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l mp = 0 0 mp mat = [[], [], [], []] [[], [], [], []] mat A = 0 0 A mp += 10 * (len(mat[j]) - 1) 10 * (len(mat[j]) - 1) mp mp += 1 * abs(abc[j] - sum(mat[j])) 1 * abs(abc[j] - sum(mat[j])) mp minmp = min(minmp, mp) min(minmp, mp) minmp
n, *abc = [int(x) for x in input().split()]
l = [int(input()) for i in range(n)]
A = 0; B = 1; C = 2;

minmp = 10 ** 9
for k in range(2 ** (2 * n)):
    mat = [[], [], [], []]  # mat[0]:= Aの材料, mat[1]:=Bの材料, mat[2]:=Cの材料
    # for i = 0, ..., N-1
    # kの 2*i & 2*i+1ビット目が 0b00: l[i]はAに使う
    #     ↑lsbから             0b01: l[i]はBに使う
    #                         0b10: l[i]はCに使う
    #                         0b11: l[i]は使わない
    for i in range(n):
        mat[k & (0b11)].append(l[i])
        k >>= 2

    if len(mat[0]) == 0 or len(mat[1]) == 0 or len(mat[2]) == 0:
        continue

    mp = 0
    for j in range(3):
        mp += 10 * (len(mat[j]) - 1)
        mp += 1 * abs(abc[j] - sum(mat[j]))

    minmp = min(minmp, mp)

print(minmp)