n,a,b,c, = map(int,input().split())
l = list(int(input()) for i in range(n))
ans = 10 ** 6
for i in range(4 ** n):
    m = i
    j = 0
    x,xp,y,yp,z,zp = 0,0,0,0,0,0
    while m > 0:
        p = m % 4
        if p == 1:
            x += l[j]
            xp += 1
        elif p == 2:
            y += l[j]
            yp += 1
        elif p == 3:
            z += l[j]
            zp += 1
        else:
            pass
        m = m // 4
        j += 1
    if xp != 0 and yp != 0 and zp != 0:
        t = abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10)
        ans = min(ans,t)
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 l = list(int(input()) for i in range(n)) l list(int(input()) for i in range(n)) list int(input()) int input() input ans = 10 ** 6 ans 10 ** 6 10 6 for i in range(4 ** n):
    m = i
    j = 0
    x,xp,y,yp,z,zp = 0,0,0,0,0,0
    while m > 0:
        p = m % 4
        if p == 1:
            x += l[j]
            xp += 1
        elif p == 2:
            y += l[j]
            yp += 1
        elif p == 3:
            z += l[j]
            zp += 1
        else:
            pass
        m = m // 4
        j += 1
    if xp != 0 and yp != 0 and zp != 0:
        t = abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10)
        ans = min(ans,t) i range(4 ** n) range 4 ** n 4 n m = i m i j = 0 j 0 x,xp,y,yp,z,zp = 0,0,0,0,0,0 x 0 xp 0 y 0 yp 0 z 0 zp 0 while m > 0:
        p = m % 4
        if p == 1:
            x += l[j]
            xp += 1
        elif p == 2:
            y += l[j]
            yp += 1
        elif p == 3:
            z += l[j]
            zp += 1
        else:
            pass
        m = m // 4
        j += 1
     m > 0 m 0 p = m % 4 p m % 4 m 4 if p == 1:
            x += l[j]
            xp += 1
        elif p == 2:
            y += l[j]
            yp += 1
        elif p == 3:
            z += l[j]
            zp += 1
        else:
            pass
         p == 1 p 1 x += l[j] x l[j] l j xp += 1 xp 1 elif p == 2:
            y += l[j]
            yp += 1
         p == 2 p 2 y += l[j] y l[j] l j yp += 1 yp 1 elif p == 3:
            z += l[j]
            zp += 1
         p == 3 p 3 z += l[j] z l[j] l j zp += 1 zp 1 m = m // 4 m m // 4 m 4 j += 1 j 1 if xp != 0 and yp != 0 and zp != 0:
        t = abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10)
        ans = min(ans,t) xp != 0 and yp != 0 and zp != 0 xp != 0 and yp != 0 xp != 0 xp 0 yp != 0 yp 0 zp != 0 zp 0 t = abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10) t abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10) abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) abs(a-x) + abs(b-y) + abs(c-z) abs(a-x) + abs(b-y) abs(a-x) abs a-x a x abs(b-y) abs b-y b y abs(c-z) abs c-z c z (xp-1)*10 xp-1 xp 1 10 (yp-1)*10 yp-1 yp 1 10 (zp-1)*10 zp-1 zp 1 10 ans = min(ans,t) ans min(ans,t) min ans t print(ans) print ans y += l[j] l[j] y zp = 0,0,0,0,0,0 0 zp xp,y,yp,z,zp = 0,0,0,0,0,0 0 xp zp += 1 1 zp yp,z,zp = 0,0,0,0,0,0 0 yp yp += 1 1 yp xp += 1 1 xp z,zp = 0,0,0,0,0,0 0 z a,b,c, = map(int,input().split()) map(int,input().split()) a m = i i m x,xp,y,yp,z,zp = 0,0,0,0,0,0 0 x c, = map(int,input().split()) map(int,input().split()) c b,c, = map(int,input().split()) map(int,input().split()) b x += l[j] l[j] x y,yp,z,zp = 0,0,0,0,0,0 0 y ans = 10 ** 6 10 ** 6 ans j = 0 0 j p = m % 4 m % 4 p m = m // 4 m // 4 m l = list(int(input()) for i in range(n)) list(int(input()) for i in range(n)) l j += 1 1 j z += l[j] l[j] z t = abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10) abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10) t n,a,b,c, = map(int,input().split()) map(int,input().split()) n ans = min(ans,t) min(ans,t) ans
n,a,b,c, = map(int,input().split())
l = list(int(input()) for i in range(n))
ans = 10 ** 6
for i in range(4 ** n):
    m = i
    j = 0
    x,xp,y,yp,z,zp = 0,0,0,0,0,0
    while m > 0:
        p = m % 4
        if p == 1:
            x += l[j]
            xp += 1
        elif p == 2:
            y += l[j]
            yp += 1
        elif p == 3:
            z += l[j]
            zp += 1
        else:
            pass
        m = m // 4
        j += 1
    if xp != 0 and yp != 0 and zp != 0:
        t = abs(a-x) + abs(b-y) + abs(c-z) + ((xp-1)*10) + ((yp-1)*10) + ((zp-1)*10)
        ans = min(ans,t)
print(ans)