def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

def f(a,la,A):
    if la == 0:
        return 1e12
    return (la-1)*10 + abs(a-A)

N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]

ans = 1e12
for i in range(4**N+1):
    tmp = list(base_10_to_n(i,4).zfill(N))
    a,la,b,lb,c,lc = 0,0,0,0,0,0
    for s,t in zip(tmp,l):
        if s == "1":
            a += t
            la += 1
        elif s == "2":
            b += t
            lb += 1
        elif s == "3":
            c += t
            lc += 1
    ans = min(ans,f(a,la,A)+f(b,lb,B)+f(c,lc,C))

print(ans) def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) base_10_to_n if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
     int(X/n) int X/n X n return base_10_to_n(int(X/n), n)+str(X%n) base_10_to_n(int(X/n), n)+str(X%n) base_10_to_n(int(X/n), n) base_10_to_n int(X/n) int X/n X n n str(X%n) str X%n X n return str(X%n) str(X%n) str X%n X n X X n n def f(a,la,A):
    if la == 0:
        return 1e12
    return (la-1)*10 + abs(a-A) f if la == 0:
        return 1e12
     la == 0 la 0 return 1e12 1e12 return (la-1)*10 + abs(a-A) (la-1)*10 + abs(a-A) (la-1)*10 la-1 la 1 10 abs(a-A) abs a-A a A a a la la A A 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)] ans = 1e12 ans 1e12 for i in range(4**N+1):
    tmp = list(base_10_to_n(i,4).zfill(N))
    a,la,b,lb,c,lc = 0,0,0,0,0,0
    for s,t in zip(tmp,l):
        if s == "1":
            a += t
            la += 1
        elif s == "2":
            b += t
            lb += 1
        elif s == "3":
            c += t
            lc += 1
    ans = min(ans,f(a,la,A)+f(b,lb,B)+f(c,lc,C)) i range(4**N+1) range 4**N+1 4**N 4 N 1 tmp = list(base_10_to_n(i,4).zfill(N)) tmp list(base_10_to_n(i,4).zfill(N)) list base_10_to_n(i,4).zfill(N) (i,4).zfill (i,4) base_10_to_n i 4 zfill N a,la,b,lb,c,lc = 0,0,0,0,0,0 a 0 la 0 b 0 lb 0 c 0 lc 0 for s,t in zip(tmp,l):
        if s == "1":
            a += t
            la += 1
        elif s == "2":
            b += t
            lb += 1
        elif s == "3":
            c += t
            lc += 1
     s t zip(tmp,l) zip tmp l if s == "1":
            a += t
            la += 1
        elif s == "2":
            b += t
            lb += 1
        elif s == "3":
            c += t
            lc += 1
     s == "1" s "1" a += t a t la += 1 la 1 elif s == "2":
            b += t
            lb += 1
         s == "2" s "2" b += t b t lb += 1 lb 1 elif s == "3":
            c += t
            lc += 1
     s == "3" s "3" c += t c t lc += 1 lc 1 ans = min(ans,f(a,la,A)+f(b,lb,B)+f(c,lc,C)) ans min(ans,f(a,la,A)+f(b,lb,B)+f(c,lc,C)) min ans f(a,la,A)+f(b,lb,B)+f(c,lc,C) f(a,la,A)+f(b,lb,B) f(a,la,A) f a la A f(b,lb,B) f b lb B f(c,lc,C) f c lc C print(ans) print ans A,B,C = map(int,input().split()) map(int,input().split()) A tmp = list(base_10_to_n(i,4).zfill(N)) list(base_10_to_n(i,4).zfill(N)) tmp lb += 1 1 lb c += t t c b,lb,c,lc = 0,0,0,0,0,0 0 b c,lc = 0,0,0,0,0,0 0 c b += t t b def f(a,la,A):
    if la == 0:
        return 1e12
    return (la-1)*10 + abs(a-A) def f(a,la,A):
    if la == 0:
        return 1e12
    return (la-1)*10 + abs(a-A) f B,C = map(int,input().split()) map(int,input().split()) B lc += 1 1 lc lc = 0,0,0,0,0,0 0 lc a += t t a l = [int(input()) for i in range(N)] [int(input()) for i in range(N)] l a,la,b,lb,c,lc = 0,0,0,0,0,0 0 a ans = min(ans,f(a,la,A)+f(b,lb,B)+f(c,lc,C)) min(ans,f(a,la,A)+f(b,lb,B)+f(c,lc,C)) ans def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) base_10_to_n N,A,B,C = map(int,input().split()) map(int,input().split()) N C = map(int,input().split()) map(int,input().split()) C ans = 1e12 1e12 ans la += 1 1 la lb,c,lc = 0,0,0,0,0,0 0 lb la,b,lb,c,lc = 0,0,0,0,0,0 0 la
def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

def f(a,la,A):
    if la == 0:
        return 1e12
    return (la-1)*10 + abs(a-A)

N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]

ans = 1e12
for i in range(4**N+1):
    tmp = list(base_10_to_n(i,4).zfill(N))
    a,la,b,lb,c,lc = 0,0,0,0,0,0
    for s,t in zip(tmp,l):
        if s == "1":
            a += t
            la += 1
        elif s == "2":
            b += t
            lb += 1
        elif s == "3":
            c += t
            lc += 1
    ans = min(ans,f(a,la,A)+f(b,lb,B)+f(c,lc,C))

print(ans)