def f(x):
    if len(x) == n:
        p.append(x)
    else:
        for i in S:
            f(x+[i])

n , a , b , c = map(int,input().split())
take = [int(input()) for i in range(n)]
S = [0,1,2,3]
p = []
f([])
ans = 10**9
for i in range(len(p)):
    sai = [0,0,0]
    cou = 0
    for j in range(n):
        if p[i][j] != 3:
            if sai[p[i][j]] == 0:
                cou -= 10
            sai[p[i][j]] += take[j]
            cou += 10
    sai.sort()
    if sai[0] == 0:
        continue
    cou += abs(sai[0]-c)+abs(sai[1]-b)+abs(sai[2]-a)
    ans = min(ans,cou)
    
print(ans) def f(x):
    if len(x) == n:
        p.append(x)
    else:
        for i in S:
            f(x+[i]) f if len(x) == n:
        p.append(x)
    else:
        for i in S:
            f(x+[i]) len(x) == n len(x) len x n p.append(x) p.append p append x for i in S:
            f(x+[i]) i S f(x+[i]) f x+[i] x [i] i x x 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 take = [int(input()) for i in range(n)] take [int(input()) for i in range(n)] S = [0,1,2,3] S [0,1,2,3] 0 1 2 3 p = [] p [] f([]) f [] ans = 10**9 ans 10**9 10 9 for i in range(len(p)):
    sai = [0,0,0]
    cou = 0
    for j in range(n):
        if p[i][j] != 3:
            if sai[p[i][j]] == 0:
                cou -= 10
            sai[p[i][j]] += take[j]
            cou += 10
    sai.sort()
    if sai[0] == 0:
        continue
    cou += abs(sai[0]-c)+abs(sai[1]-b)+abs(sai[2]-a)
    ans = min(ans,cou)
     i range(len(p)) range len(p) len p sai = [0,0,0] sai [0,0,0] 0 0 0 cou = 0 cou 0 for j in range(n):
        if p[i][j] != 3:
            if sai[p[i][j]] == 0:
                cou -= 10
            sai[p[i][j]] += take[j]
            cou += 10
     j range(n) range n if p[i][j] != 3:
            if sai[p[i][j]] == 0:
                cou -= 10
            sai[p[i][j]] += take[j]
            cou += 10
     p[i][j] != 3 p[i][j] [i] p i j 3 if sai[p[i][j]] == 0:
                cou -= 10
             sai[p[i][j]] == 0 sai[p[i][j]] sai p[i][j] [i] p i j 0 cou -= 10 cou 10 sai[p[i][j]] += take[j] sai[p[i][j]] sai p[i][j] [i] p i j take[j] take j cou += 10 cou 10 sai.sort() sai.sort sai sort if sai[0] == 0:
        continue
     sai[0] == 0 sai[0] sai 0 0 continue cou += abs(sai[0]-c)+abs(sai[1]-b)+abs(sai[2]-a) cou abs(sai[0]-c)+abs(sai[1]-b)+abs(sai[2]-a) abs(sai[0]-c)+abs(sai[1]-b) abs(sai[0]-c) abs sai[0]-c sai[0] sai 0 c abs(sai[1]-b) abs sai[1]-b sai[1] sai 1 b abs(sai[2]-a) abs sai[2]-a sai[2] sai 2 a ans = min(ans,cou) ans min(ans,cou) min ans cou print(ans) print ans def f(x):
    if len(x) == n:
        p.append(x)
    else:
        for i in S:
            f(x+[i]) def f(x):
    if len(x) == n:
        p.append(x)
    else:
        for i in S:
            f(x+[i]) f take = [int(input()) for i in range(n)] [int(input()) for i in range(n)] take cou = 0 0 cou cou += 10 10 cou cou += abs(sai[0]-c)+abs(sai[1]-b)+abs(sai[2]-a) abs(sai[0]-c)+abs(sai[1]-b)+abs(sai[2]-a) cou a , b , c = map(int,input().split()) map(int,input().split()) a S = [0,1,2,3] [0,1,2,3] S ans = min(ans,cou) min(ans,cou) ans sai = [0,0,0] [0,0,0] sai n , a , b , c = map(int,input().split()) map(int,input().split()) n p = [] [] p b , c = map(int,input().split()) map(int,input().split()) b cou -= 10 10 cou c = map(int,input().split()) map(int,input().split()) c ans = 10**9 10**9 ans
def f(x):
    if len(x) == n:
        p.append(x)
    else:
        for i in S:
            f(x+[i])

n , a , b , c = map(int,input().split())
take = [int(input()) for i in range(n)]
S = [0,1,2,3]
p = []
f([])
ans = 10**9
for i in range(len(p)):
    sai = [0,0,0]
    cou = 0
    for j in range(n):
        if p[i][j] != 3:
            if sai[p[i][j]] == 0:
                cou -= 10
            sai[p[i][j]] += take[j]
            cou += 10
    sai.sort()
    if sai[0] == 0:
        continue
    cou += abs(sai[0]-c)+abs(sai[1]-b)+abs(sai[2]-a)
    ans = min(ans,cou)
    
print(ans)