n, a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]

import itertools
set123 = set([1,2,3])
ans = 10 ** 10
for i in itertools.product([0,1,2,3], repeat=n):
    if len(set(i) & set123) < 3:
        continue
    mp = 0
    ai = 0
    bi = 0
    ci = 0
    for j in range(n):
        if i[j] == 0:
            continue
        if i[j] == 1:
            if ai > 0:
                mp += 10
            ai += l[j]
        if i[j] == 2:
            if bi > 0:
                mp += 10
            bi += l[j]
        if i[j] == 3:
            if ci > 0:
                mp += 10
            ci += l[j]
    mp += abs(ai - a)
    mp += abs(bi - b)
    mp += abs(ci - c)
    ans = min(ans, mp)
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)] import itertools itertools set123 = set([1,2,3]) set123 set([1,2,3]) set [1,2,3] 1 2 3 ans = 10 ** 10 ans 10 ** 10 10 10 for i in itertools.product([0,1,2,3], repeat=n):
    if len(set(i) & set123) < 3:
        continue
    mp = 0
    ai = 0
    bi = 0
    ci = 0
    for j in range(n):
        if i[j] == 0:
            continue
        if i[j] == 1:
            if ai > 0:
                mp += 10
            ai += l[j]
        if i[j] == 2:
            if bi > 0:
                mp += 10
            bi += l[j]
        if i[j] == 3:
            if ci > 0:
                mp += 10
            ci += l[j]
    mp += abs(ai - a)
    mp += abs(bi - b)
    mp += abs(ci - c)
    ans = min(ans, mp) i itertools.product([0,1,2,3], repeat=n) itertools.product itertools product [0,1,2,3] 0 1 2 3 repeat=n repeat n if len(set(i) & set123) < 3:
        continue
     len(set(i) & set123) < 3 len(set(i) & set123) len set(i) & set123 set(i) set i set123 3 continue mp = 0 mp 0 ai = 0 ai 0 bi = 0 bi 0 ci = 0 ci 0 for j in range(n):
        if i[j] == 0:
            continue
        if i[j] == 1:
            if ai > 0:
                mp += 10
            ai += l[j]
        if i[j] == 2:
            if bi > 0:
                mp += 10
            bi += l[j]
        if i[j] == 3:
            if ci > 0:
                mp += 10
            ci += l[j]
     j range(n) range n if i[j] == 0:
            continue
         i[j] == 0 i[j] i j 0 continue if i[j] == 1:
            if ai > 0:
                mp += 10
            ai += l[j]
         i[j] == 1 i[j] i j 1 if ai > 0:
                mp += 10
             ai > 0 ai 0 mp += 10 mp 10 ai += l[j] ai l[j] l j if i[j] == 2:
            if bi > 0:
                mp += 10
            bi += l[j]
         i[j] == 2 i[j] i j 2 if bi > 0:
                mp += 10
             bi > 0 bi 0 mp += 10 mp 10 bi += l[j] bi l[j] l j if i[j] == 3:
            if ci > 0:
                mp += 10
            ci += l[j]
     i[j] == 3 i[j] i j 3 if ci > 0:
                mp += 10
             ci > 0 ci 0 mp += 10 mp 10 ci += l[j] ci l[j] l j mp += abs(ai - a) mp abs(ai - a) abs ai - a ai a mp += abs(bi - b) mp abs(bi - b) abs bi - b bi b mp += abs(ci - c) mp abs(ci - c) abs ci - c ci c ans = min(ans, mp) ans min(ans, mp) min ans mp print(ans) print ans mp += 10 10 mp ans = min(ans, mp) min(ans, mp) ans ans = 10 ** 10 10 ** 10 ans c = map(int, input().split()) map(int, input().split()) c mp += abs(ai - a) abs(ai - a) mp b,c = map(int, input().split()) map(int, input().split()) b set123 = set([1,2,3]) set([1,2,3]) set123 mp = 0 0 mp mp += 10 10 mp mp += 10 10 mp ai = 0 0 ai mp += abs(ci - c) abs(ci - c) mp a,b,c = map(int, input().split()) map(int, input().split()) a n, a,b,c = map(int, input().split()) map(int, input().split()) n bi = 0 0 bi ci += l[j] l[j] ci bi += l[j] l[j] bi l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l ci = 0 0 ci ai += l[j] l[j] ai mp += abs(bi - b) abs(bi - b) mp
n, a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]

import itertools
set123 = set([1,2,3])
ans = 10 ** 10
for i in itertools.product([0,1,2,3], repeat=n):
    if len(set(i) & set123) < 3:
        continue
    mp = 0
    ai = 0
    bi = 0
    ci = 0
    for j in range(n):
        if i[j] == 0:
            continue
        if i[j] == 1:
            if ai > 0:
                mp += 10
            ai += l[j]
        if i[j] == 2:
            if bi > 0:
                mp += 10
            bi += l[j]
        if i[j] == 3:
            if ci > 0:
                mp += 10
            ci += l[j]
    mp += abs(ai - a)
    mp += abs(bi - b)
    mp += abs(ci - c)
    ans = min(ans, mp)
print(ans)
