# Problem C - Synthetic Kadomatsu

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

# dfs search
class DFS:

    def __init__(self, l_list, N, A, B, C):
        self.l_list = l_list
        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.INF = float('INF')
        self.ans = float('INF')

    def get_ans(self):
        return self.ans

    def dfs(self, n, a, b, c):
        if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
        self.ans = min(self.ans, self.dfs(n+1, a, b, c))

        # A, B, C を利用する場合
        if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

        if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

        if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

        return self.ans

# calc
dfs_obj = DFS(l_list, N, A, B, C)
dfs_obj.dfs(0, 0, 0, 0)

# output
print(dfs_obj.get_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 = [0]*N l_list [0]*N [0] 0 N for i in range(N):
    l = int(input())
    l_list[i] = l

# dfs search i range(N) range N l = int(input()) l int(input()) int input() input l_list[i] = l l_list[i] l_list i l class DFS:

    def __init__(self, l_list, N, A, B, C):
        self.l_list = l_list
        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.INF = float('INF')
        self.ans = float('INF')

    def get_ans(self):
        return self.ans

    def dfs(self, n, a, b, c):
        if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
        self.ans = min(self.ans, self.dfs(n+1, a, b, c))

        # A, B, C を利用する場合
        if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

        if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

        if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

        return self.ans

# calc DFS def __init__(self, l_list, N, A, B, C):
        self.l_list = l_list
        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.INF = float('INF')
        self.ans = float('INF')

     __init__ self.l_list = l_list self.l_list self l_list l_list self.N = N self.N self N N self.A = A self.A self A A self.B = B self.B self B B self.C = C self.C self C C self.INF = float('INF') self.INF self INF float('INF') float 'INF' self.ans = float('INF') self.ans self ans float('INF') float 'INF' self self l_list l_list N N A A B B C C def get_ans(self):
        return self.ans

     get_ans return self.ans self.ans self ans self self def dfs(self, n, a, b, c):
        if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
        self.ans = min(self.ans, self.dfs(n+1, a, b, c))

        # A, B, C を利用する場合
        if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

        if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

        if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

        return self.ans

# calc dfs if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
         n==self.N n self.N self N if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
         not a==0 and not b==0 and not c==0 not a==0 and not b==0 not a==0 a==0 a 0 not b==0 b==0 b 0 not c==0 c==0 c 0 return abs(a-self.A) + abs(b-self.B) + abs(c-self.C) abs(a-self.A) + abs(b-self.B) + abs(c-self.C) abs(a-self.A) + abs(b-self.B) abs(a-self.A) abs a-self.A a self.A self A abs(b-self.B) abs b-self.B b self.B self B abs(c-self.C) abs c-self.C c self.C self C return self.INF self.INF self INF self.ans = min(self.ans, self.dfs(n+1, a, b, c)) self.ans self ans min(self.ans, self.dfs(n+1, a, b, c)) min self.ans self ans self.dfs(n+1, a, b, c) self.dfs self dfs n+1 n 1 a b c if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

         a==0 a 0 self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c)) self.ans self ans min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c)) min self.ans self ans self.dfs(n+1, a+self.l_list[n], b, c) self.dfs self dfs n+1 n 1 a+self.l_list[n] a self.l_list[n] self.l_list self l_list n b c self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10) self.ans self ans min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10) min self.ans self ans self.dfs(n+1, a+self.l_list[n], b, c) + 10 self.dfs(n+1, a+self.l_list[n], b, c) self.dfs self dfs n+1 n 1 a+self.l_list[n] a self.l_list[n] self.l_list self l_list n b c 10 if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

         b==0 b 0 self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c)) self.ans self ans min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c)) min self.ans self ans self.dfs(n+1, a, b+self.l_list[n], c) self.dfs self dfs n+1 n 1 a b+self.l_list[n] b self.l_list[n] self.l_list self l_list n c self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10) self.ans self ans min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10) min self.ans self ans self.dfs(n+1, a, b+self.l_list[n], c) + 10 self.dfs(n+1, a, b+self.l_list[n], c) self.dfs self dfs n+1 n 1 a b+self.l_list[n] b self.l_list[n] self.l_list self l_list n c 10 if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

         c==0 c 0 self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n])) self.ans self ans min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n])) min self.ans self ans self.dfs(n+1, a, b, c+self.l_list[n]) self.dfs self dfs n+1 n 1 a b c+self.l_list[n] c self.l_list[n] self.l_list self l_list n self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10) self.ans self ans min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10) min self.ans self ans self.dfs(n+1, a, b, c+self.l_list[n]) + 10 self.dfs(n+1, a, b, c+self.l_list[n]) self.dfs self dfs n+1 n 1 a b c+self.l_list[n] c self.l_list[n] self.l_list self l_list n 10 return self.ans self.ans self ans self self n n a a b b c c dfs_obj = DFS(l_list, N, A, B, C) dfs_obj DFS(l_list, N, A, B, C) DFS l_list N A B C dfs_obj.dfs(0, 0, 0, 0) dfs_obj.dfs dfs_obj dfs 0 0 0 0 print(dfs_obj.get_ans()) print dfs_obj.get_ans() dfs_obj.get_ans dfs_obj get_ans B, C = map(int, input().split()) map(int, input().split()) B l = int(input()) int(input()) l dfs_obj = DFS(l_list, N, A, B, C) DFS(l_list, N, A, B, C) dfs_obj A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C class DFS:

    def __init__(self, l_list, N, A, B, C):
        self.l_list = l_list
        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.INF = float('INF')
        self.ans = float('INF')

    def get_ans(self):
        return self.ans

    def dfs(self, n, a, b, c):
        if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
        self.ans = min(self.ans, self.dfs(n+1, a, b, c))

        # A, B, C を利用する場合
        if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

        if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

        if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

        return self.ans

# calc class DFS:

    def __init__(self, l_list, N, A, B, C):
        self.l_list = l_list
        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.INF = float('INF')
        self.ans = float('INF')

    def get_ans(self):
        return self.ans

    def dfs(self, n, a, b, c):
        if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
        self.ans = min(self.ans, self.dfs(n+1, a, b, c))

        # A, B, C を利用する場合
        if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

        if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

        if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

        return self.ans

# calc DFS l_list = [0]*N [0]*N l_list N, A, B, C = map(int, input().split()) map(int, input().split()) N
# Problem C - Synthetic Kadomatsu

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

# dfs search
class DFS:

    def __init__(self, l_list, N, A, B, C):
        self.l_list = l_list
        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.INF = float('INF')
        self.ans = float('INF')

    def get_ans(self):
        return self.ans

    def dfs(self, n, a, b, c):
        if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
        self.ans = min(self.ans, self.dfs(n+1, a, b, c))

        # A, B, C を利用する場合
        if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

        if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

        if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

        return self.ans

# calc
dfs_obj = DFS(l_list, N, A, B, C)
dfs_obj.dfs(0, 0, 0, 0)

# output
print(dfs_obj.get_ans())
