import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    INF = 10**18    

    # 最小消費MP
    def rec(i, a, b, c):# i:現在使った本数　a,b,c：現在の竹の長さ
        # 全て竹使ったら理想とのズレを魔法1,2で埋めてく
        if i == N:
            if not a or not b or not c:
                return INF
            return abs(a-A)+abs(b-B)+abs(c-C)
        
        # 竹不採用
        res = rec(i+1, a, b, c)
        # a採用
        if a >= 1:
            res = min(res, rec(i+1, a+L[i], b, c)+10)
        else:
            res = min(res, rec(i+1, a+L[i], b, c))
        # b採用
        if b >= 1:
            res = min(res, rec(i+1, a, b+L[i], c)+10)
        else:
            res = min(res, rec(i+1, a, b+L[i], c))
        
        # c採用
        if c >= 1:
            res = min(res, rec(i+1, a, b, c+L[i])+10)
        else:
            res = min(res, rec(i+1, a, b, c+L[i]))

        return res

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

    print(rec(0, 0, 0, 0))

resolve() import sys sys sys.setrecursionlimit(10 ** 5 + 10) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 + 10 10 ** 5 10 5 10 def input(): return sys.stdin.readline().strip() input def resolve():
    INF = 10**18    

    # 最小消費MP
    def rec(i, a, b, c):# i:現在使った本数　a,b,c：現在の竹の長さ
        # 全て竹使ったら理想とのズレを魔法1,2で埋めてく
        if i == N:
            if not a or not b or not c:
                return INF
            return abs(a-A)+abs(b-B)+abs(c-C)
        
        # 竹不採用
        res = rec(i+1, a, b, c)
        # a採用
        if a >= 1:
            res = min(res, rec(i+1, a+L[i], b, c)+10)
        else:
            res = min(res, rec(i+1, a+L[i], b, c))
        # b採用
        if b >= 1:
            res = min(res, rec(i+1, a, b+L[i], c)+10)
        else:
            res = min(res, rec(i+1, a, b+L[i], c))
        
        # c採用
        if c >= 1:
            res = min(res, rec(i+1, a, b, c+L[i])+10)
        else:
            res = min(res, rec(i+1, a, b, c+L[i]))

        return res

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

    print(rec(0, 0, 0, 0)) resolve INF = 10**18 INF 10**18 10 18 def rec(i, a, b, c):# i:現在使った本数　a,b,c：現在の竹の長さ
        # 全て竹使ったら理想とのズレを魔法1,2で埋めてく
        if i == N:
            if not a or not b or not c:
                return INF
            return abs(a-A)+abs(b-B)+abs(c-C)
        
        # 竹不採用
        res = rec(i+1, a, b, c)
        # a採用
        if a >= 1:
            res = min(res, rec(i+1, a+L[i], b, c)+10)
        else:
            res = min(res, rec(i+1, a+L[i], b, c))
        # b採用
        if b >= 1:
            res = min(res, rec(i+1, a, b+L[i], c)+10)
        else:
            res = min(res, rec(i+1, a, b+L[i], c))
        
        # c採用
        if c >= 1:
            res = min(res, rec(i+1, a, b, c+L[i])+10)
        else:
            res = min(res, rec(i+1, a, b, c+L[i]))

        return res

     rec if i == N:
            if not a or not b or not c:
                return INF
            return abs(a-A)+abs(b-B)+abs(c-C)
        
        # 竹不採用
         i == N i N if not a or not b or not c:
                return INF
             not a or not b or not c not a or not b not a a not b b not c c return INF INF return abs(a-A)+abs(b-B)+abs(c-C) abs(a-A)+abs(b-B)+abs(c-C) abs(a-A)+abs(b-B) abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C res = rec(i+1, a, b, c) res rec(i+1, a, b, c) rec i+1 i 1 a b c if a >= 1:
            res = min(res, rec(i+1, a+L[i], b, c)+10)
        else:
            res = min(res, rec(i+1, a+L[i], b, c))
        # b採用
         a >= 1 a 1 res = min(res, rec(i+1, a+L[i], b, c)+10) res min(res, rec(i+1, a+L[i], b, c)+10) min res rec(i+1, a+L[i], b, c)+10 rec(i+1, a+L[i], b, c) rec i+1 i 1 a+L[i] a L[i] L i b c 10 res = min(res, rec(i+1, a+L[i], b, c)) res min(res, rec(i+1, a+L[i], b, c)) min res rec(i+1, a+L[i], b, c) rec i+1 i 1 a+L[i] a L[i] L i b c if b >= 1:
            res = min(res, rec(i+1, a, b+L[i], c)+10)
        else:
            res = min(res, rec(i+1, a, b+L[i], c))
        
        # c採用
         b >= 1 b 1 res = min(res, rec(i+1, a, b+L[i], c)+10) res min(res, rec(i+1, a, b+L[i], c)+10) min res rec(i+1, a, b+L[i], c)+10 rec(i+1, a, b+L[i], c) rec i+1 i 1 a b+L[i] b L[i] L i c 10 res = min(res, rec(i+1, a, b+L[i], c)) res min(res, rec(i+1, a, b+L[i], c)) min res rec(i+1, a, b+L[i], c) rec i+1 i 1 a b+L[i] b L[i] L i c if c >= 1:
            res = min(res, rec(i+1, a, b, c+L[i])+10)
        else:
            res = min(res, rec(i+1, a, b, c+L[i]))

         c >= 1 c 1 res = min(res, rec(i+1, a, b, c+L[i])+10) res min(res, rec(i+1, a, b, c+L[i])+10) min res rec(i+1, a, b, c+L[i])+10 rec(i+1, a, b, c+L[i]) rec i+1 i 1 a b c+L[i] c L[i] L i 10 res = min(res, rec(i+1, a, b, c+L[i])) res min(res, rec(i+1, a, b, c+L[i])) min res rec(i+1, a, b, c+L[i]) rec i+1 i 1 a b c+L[i] c L[i] L i return res res i i a a b b c c 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)] print(rec(0, 0, 0, 0)) print rec(0, 0, 0, 0) rec 0 0 0 0 resolve() resolve def resolve():
    INF = 10**18    

    # 最小消費MP
    def rec(i, a, b, c):# i:現在使った本数　a,b,c：現在の竹の長さ
        # 全て竹使ったら理想とのズレを魔法1,2で埋めてく
        if i == N:
            if not a or not b or not c:
                return INF
            return abs(a-A)+abs(b-B)+abs(c-C)
        
        # 竹不採用
        res = rec(i+1, a, b, c)
        # a採用
        if a >= 1:
            res = min(res, rec(i+1, a+L[i], b, c)+10)
        else:
            res = min(res, rec(i+1, a+L[i], b, c))
        # b採用
        if b >= 1:
            res = min(res, rec(i+1, a, b+L[i], c)+10)
        else:
            res = min(res, rec(i+1, a, b+L[i], c))
        
        # c採用
        if c >= 1:
            res = min(res, rec(i+1, a, b, c+L[i])+10)
        else:
            res = min(res, rec(i+1, a, b, c+L[i]))

        return res

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

    print(rec(0, 0, 0, 0)) def resolve():
    INF = 10**18    

    # 最小消費MP
    def rec(i, a, b, c):# i:現在使った本数　a,b,c：現在の竹の長さ
        # 全て竹使ったら理想とのズレを魔法1,2で埋めてく
        if i == N:
            if not a or not b or not c:
                return INF
            return abs(a-A)+abs(b-B)+abs(c-C)
        
        # 竹不採用
        res = rec(i+1, a, b, c)
        # a採用
        if a >= 1:
            res = min(res, rec(i+1, a+L[i], b, c)+10)
        else:
            res = min(res, rec(i+1, a+L[i], b, c))
        # b採用
        if b >= 1:
            res = min(res, rec(i+1, a, b+L[i], c)+10)
        else:
            res = min(res, rec(i+1, a, b+L[i], c))
        
        # c採用
        if c >= 1:
            res = min(res, rec(i+1, a, b, c+L[i])+10)
        else:
            res = min(res, rec(i+1, a, b, c+L[i]))

        return res

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

    print(rec(0, 0, 0, 0)) resolve def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    INF = 10**18    

    # 最小消費MP
    def rec(i, a, b, c):# i:現在使った本数　a,b,c：現在の竹の長さ
        # 全て竹使ったら理想とのズレを魔法1,2で埋めてく
        if i == N:
            if not a or not b or not c:
                return INF
            return abs(a-A)+abs(b-B)+abs(c-C)
        
        # 竹不採用
        res = rec(i+1, a, b, c)
        # a採用
        if a >= 1:
            res = min(res, rec(i+1, a+L[i], b, c)+10)
        else:
            res = min(res, rec(i+1, a+L[i], b, c))
        # b採用
        if b >= 1:
            res = min(res, rec(i+1, a, b+L[i], c)+10)
        else:
            res = min(res, rec(i+1, a, b+L[i], c))
        
        # c採用
        if c >= 1:
            res = min(res, rec(i+1, a, b, c+L[i])+10)
        else:
            res = min(res, rec(i+1, a, b, c+L[i]))

        return res

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

    print(rec(0, 0, 0, 0))

resolve()