def main():
    N, A, B, C = (int(_) for _ in input().split())
    L = [int(input()) for _ in range(N)]
    INF = 10 ** 12

    def dfs(i, a, b, c):
        if i == N:
            return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
        c0 = dfs(i+1, a, b, c)
        c1 = dfs(i+1, a+L[i], b, c) + 10
        c2 = dfs(i+1, a, b+L[i], c) + 10
        c3 = dfs(i+1, a, b, c+L[i]) + 10
        return min(c0, c1, c2, c3)

    print(dfs(0, 0, 0, 0))
    return

if __name__ == '__main__':
    main() def main():
    N, A, B, C = (int(_) for _ in input().split())
    L = [int(input()) for _ in range(N)]
    INF = 10 ** 12

    def dfs(i, a, b, c):
        if i == N:
            return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
        c0 = dfs(i+1, a, b, c)
        c1 = dfs(i+1, a+L[i], b, c) + 10
        c2 = dfs(i+1, a, b+L[i], c) + 10
        c3 = dfs(i+1, a, b, c+L[i]) + 10
        return min(c0, c1, c2, c3)

    print(dfs(0, 0, 0, 0))
    return main int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ N, A, B, C = (int(_) for _ in input().split()) N (int(_) for _ in 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 = 10 ** 12 INF 10 ** 12 10 12 def dfs(i, a, b, c):
        if i == N:
            return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
        c0 = dfs(i+1, a, b, c)
        c1 = dfs(i+1, a+L[i], b, c) + 10
        c2 = dfs(i+1, a, b+L[i], c) + 10
        c3 = dfs(i+1, a, b, c+L[i]) + 10
        return min(c0, c1, c2, c3)

     dfs if i == N:
            return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
         i == N i N return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF min(a, b, c) > 0 min(a, b, c) min a b c 0 abs(a-A)+abs(b-B)+abs(c-C)-30 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 30 INF c0 = dfs(i+1, a, b, c) c0 dfs(i+1, a, b, c) dfs i+1 i 1 a b c c1 = dfs(i+1, a+L[i], b, c) + 10 c1 dfs(i+1, a+L[i], b, c) + 10 dfs(i+1, a+L[i], b, c) dfs i+1 i 1 a+L[i] a L[i] L i b c 10 c2 = dfs(i+1, a, b+L[i], c) + 10 c2 dfs(i+1, a, b+L[i], c) + 10 dfs(i+1, a, b+L[i], c) dfs i+1 i 1 a b+L[i] b L[i] L i c 10 c3 = dfs(i+1, a, b, c+L[i]) + 10 c3 dfs(i+1, a, b, c+L[i]) + 10 dfs(i+1, a, b, c+L[i]) dfs i+1 i 1 a b c+L[i] c L[i] L i 10 return min(c0, c1, c2, c3) min(c0, c1, c2, c3) min c0 c1 c2 c3 i i a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, A, B, C = (int(_) for _ in input().split())
    L = [int(input()) for _ in range(N)]
    INF = 10 ** 12

    def dfs(i, a, b, c):
        if i == N:
            return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
        c0 = dfs(i+1, a, b, c)
        c1 = dfs(i+1, a+L[i], b, c) + 10
        c2 = dfs(i+1, a, b+L[i], c) + 10
        c3 = dfs(i+1, a, b, c+L[i]) + 10
        return min(c0, c1, c2, c3)

    print(dfs(0, 0, 0, 0))
    return def main():
    N, A, B, C = (int(_) for _ in input().split())
    L = [int(input()) for _ in range(N)]
    INF = 10 ** 12

    def dfs(i, a, b, c):
        if i == N:
            return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
        c0 = dfs(i+1, a, b, c)
        c1 = dfs(i+1, a+L[i], b, c) + 10
        c2 = dfs(i+1, a, b+L[i], c) + 10
        c3 = dfs(i+1, a, b, c+L[i]) + 10
        return min(c0, c1, c2, c3)

    print(dfs(0, 0, 0, 0))
    return main
def main():
    N, A, B, C = (int(_) for _ in input().split())
    L = [int(input()) for _ in range(N)]
    INF = 10 ** 12

    def dfs(i, a, b, c):
        if i == N:
            return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
        c0 = dfs(i+1, a, b, c)
        c1 = dfs(i+1, a+L[i], b, c) + 10
        c2 = dfs(i+1, a, b+L[i], c) + 10
        c3 = dfs(i+1, a, b, c+L[i]) + 10
        return min(c0, c1, c2, c3)

    print(dfs(0, 0, 0, 0))
    return

if __name__ == '__main__':
    main()
