def main():
    n, a, b, c = list(map(int, input().split()))
    L = [int(input()) for _ in range(n)]
    INF = 1000000
    def dfs(i, la, lb, lc):
        if i == n:
            return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF
        res = []
        res.append(dfs(i + 1, la, lb, lc))
        res.append(dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc))
        res.append(dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc))
        res.append(dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i]))
        return min(res)
    print(dfs(0, 0, 0, 0))

if __name__ == '__main__':
    main() def main():
    n, a, b, c = list(map(int, input().split()))
    L = [int(input()) for _ in range(n)]
    INF = 1000000
    def dfs(i, la, lb, lc):
        if i == n:
            return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF
        res = []
        res.append(dfs(i + 1, la, lb, lc))
        res.append(dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc))
        res.append(dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc))
        res.append(dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i]))
        return min(res)
    print(dfs(0, 0, 0, 0)) main n, a, b, c = list(map(int, input().split())) n list(map(int, input().split())) list 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)] INF = 1000000 INF 1000000 def dfs(i, la, lb, lc):
        if i == n:
            return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF
        res = []
        res.append(dfs(i + 1, la, lb, lc))
        res.append(dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc))
        res.append(dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc))
        res.append(dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i]))
        return min(res)
     dfs if i == n:
            return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF
         i == n i n return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF min(la, lb, lc) > 0 min(la, lb, lc) min la lb lc 0 abs(la - a) + abs(lb - b) + abs(lc - c) abs(la - a) + abs(lb - b) abs(la - a) abs la - a la a abs(lb - b) abs lb - b lb b abs(lc - c) abs lc - c lc c INF res = [] res [] res.append(dfs(i + 1, la, lb, lc)) res.append res append dfs(i + 1, la, lb, lc) dfs i + 1 i 1 la lb lc res.append(dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc)) res.append res append dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc) la != 0 la 0 dfs(i + 1, la + L[i], lb, lc) + 10 dfs(i + 1, la + L[i], lb, lc) dfs i + 1 i 1 la + L[i] la L[i] L i lb lc 10 dfs(i + 1, la + L[i], lb, lc) dfs i + 1 i 1 la + L[i] la L[i] L i lb lc res.append(dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc)) res.append res append dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc) lb != 0 lb 0 dfs(i + 1, la, lb + L[i], lc) + 10 dfs(i + 1, la, lb + L[i], lc) dfs i + 1 i 1 la lb + L[i] lb L[i] L i lc 10 dfs(i + 1, la, lb + L[i], lc) dfs i + 1 i 1 la lb + L[i] lb L[i] L i lc res.append(dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i])) res.append res append dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i]) lc != 0 lc 0 dfs(i + 1, la, lb, lc + L[i]) + 10 dfs(i + 1, la, lb, lc + L[i]) dfs i + 1 i 1 la lb lc + L[i] lc L[i] L i 10 dfs(i + 1, la, lb, lc + L[i]) dfs i + 1 i 1 la lb lc + L[i] lc L[i] L i return min(res) min(res) min res i i la la lb lb lc lc print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, a, b, c = list(map(int, input().split()))
    L = [int(input()) for _ in range(n)]
    INF = 1000000
    def dfs(i, la, lb, lc):
        if i == n:
            return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF
        res = []
        res.append(dfs(i + 1, la, lb, lc))
        res.append(dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc))
        res.append(dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc))
        res.append(dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i]))
        return min(res)
    print(dfs(0, 0, 0, 0)) def main():
    n, a, b, c = list(map(int, input().split()))
    L = [int(input()) for _ in range(n)]
    INF = 1000000
    def dfs(i, la, lb, lc):
        if i == n:
            return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF
        res = []
        res.append(dfs(i + 1, la, lb, lc))
        res.append(dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc))
        res.append(dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc))
        res.append(dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i]))
        return min(res)
    print(dfs(0, 0, 0, 0)) main
def main():
    n, a, b, c = list(map(int, input().split()))
    L = [int(input()) for _ in range(n)]
    INF = 1000000
    def dfs(i, la, lb, lc):
        if i == n:
            return abs(la - a) + abs(lb - b) + abs(lc - c) if min(la, lb, lc) > 0 else INF
        res = []
        res.append(dfs(i + 1, la, lb, lc))
        res.append(dfs(i + 1, la + L[i], lb, lc) + 10 if la != 0 else dfs(i + 1, la + L[i], lb, lc))
        res.append(dfs(i + 1, la, lb + L[i], lc) + 10 if lb != 0 else dfs(i + 1, la, lb + L[i], lc))
        res.append(dfs(i + 1, la, lb, lc + L[i]) + 10 if lc != 0 else dfs(i + 1, la, lb, lc + L[i]))
        return min(res)
    print(dfs(0, 0, 0, 0))

if __name__ == '__main__':
    main()