def main():
    import itertools as it
    N,A,B,C = map(int,input().split())
    pre = [int(input()) for _ in range(N)]
    if N == 3:print(A-pre[0]+B-pre[1]+C-pre[2])
    else:
        m = [0,1,2,3,4,5,6,7]
        cpm = it.permutations(pre,N)
        ccb = list(it.combinations(m[:N], 3))
        minc = 99999999999999999
        for l in cpm:
            for d in ccb:
                cmp = (d[2] - 2) * 10
                asum = abs(A - sum(l[:d[0]+1]))
                if cmp+asum >= minc: continue
                bsum = abs(B - sum(l[d[0]+1:d[1]+1]))
                if cmp+asum+bsum >= minc: continue
                csum = abs(C - sum(l[d[1]+1:d[2]+1]))
                tc = cmp+asum+bsum+csum
                minc = min(minc,tc)
    print(minc)
main()