n, a, b, c = [int(e) for e in input().split()]
L = [int(input()) for i in range(n)]

def dfs(A, B, C, O, lst, mi):
    if len(lst) == 0:
        if len(A) == 0 or len(B) == 0 or len(C) == 0:
            return mi

        mp = 0
        mp += (len(A) - 1)*10 + abs(a - sum(A))
        mp += (len(B) - 1)*10 + abs(b - sum(B))
        mp += (len(C) - 1)*10 + abs(c - sum(C))
        return min(mp, mi)

    l = lst.pop()
    mi = dfs(A + [l], B.copy(), C.copy(), O.copy(), lst.copy(), mi)
    mi = dfs(A.copy(), B + [l], C.copy(), O.copy(), lst.copy(), mi)
    mi = dfs(A.copy(), B.copy(), C + [l], O.copy(), lst.copy(), mi)
    mi = dfs(A.copy(), B.copy(), C.copy(), O + [l], lst.copy(), mi)

    return mi

def main():
    print(dfs([], [], [], [], L.copy(), float('inf')))

if __name__ == "__main__":
    main()
