import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, B, C = map(int, readline().split())
    (*L,) = map(int, read().split())

    @lru_cache(maxsize=None)
    def rec(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

        res0 = rec(i + 1, a, b, c)
        res1 = rec(i + 1, a + L[i], b, c) + 10
        res2 = rec(i + 1, a, b + L[i], c) + 10
        res3 = rec(i + 1, a, b, c + L[i]) + 10

        return min(res0, res1, res2, res3)

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


if __name__ == '__main__':
    main() import sys sys from functools import lru_cache read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, A, B, C = map(int, readline().split())
    (*L,) = map(int, read().split())

    @lru_cache(maxsize=None)
    def rec(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

        res0 = rec(i + 1, a, b, c)
        res1 = rec(i + 1, a + L[i], b, c) + 10
        res2 = rec(i + 1, a, b + L[i], c) + 10
        res3 = rec(i + 1, a, b, c + L[i]) + 10

        return min(res0, res1, res2, res3)

    print(rec(0, 0, 0, 0))
    return main N, A, B, C = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split A B C (*L,) = map(int, read().split()) *L L map(int, read().split()) map int read().split() ().split () read split def rec(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

        res0 = rec(i + 1, a, b, c)
        res1 = rec(i + 1, a + L[i], b, c) + 10
        res2 = rec(i + 1, a, b + L[i], c) + 10
        res3 = rec(i + 1, a, b, c + L[i]) + 10

        return min(res0, res1, res2, res3)

     rec 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 res0 = rec(i + 1, a, b, c) res0 rec(i + 1, a, b, c) rec i + 1 i 1 a b c res1 = rec(i + 1, a + L[i], b, c) + 10 res1 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 res2 = rec(i + 1, a, b + L[i], c) + 10 res2 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 res3 = rec(i + 1, a, b, c + L[i]) + 10 res3 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 return min(res0, res1, res2, res3) min(res0, res1, res2, res3) min res0 res1 res2 res3 i i a a b b c c @lru_cache(maxsize=None)
     rec maxsize=None @lru_cache(maxsize=None)
     lru_cache maxsize=None maxsize None rec print(rec(0, 0, 0, 0)) print rec(0, 0, 0, 0) rec 0 0 0 0 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main read = sys.stdin.read sys.stdin.read read readline = sys.stdin.readline sys.stdin.readline readline MOD = 1000000007 1000000007 MOD readlines = sys.stdin.readlines sys.stdin.readlines readlines def main():
    N, A, B, C = map(int, readline().split())
    (*L,) = map(int, read().split())

    @lru_cache(maxsize=None)
    def rec(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

        res0 = rec(i + 1, a, b, c)
        res1 = rec(i + 1, a + L[i], b, c) + 10
        res2 = rec(i + 1, a, b + L[i], c) + 10
        res3 = rec(i + 1, a, b, c + L[i]) + 10

        return min(res0, res1, res2, res3)

    print(rec(0, 0, 0, 0))
    return def main():
    N, A, B, C = map(int, readline().split())
    (*L,) = map(int, read().split())

    @lru_cache(maxsize=None)
    def rec(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

        res0 = rec(i + 1, a, b, c)
        res1 = rec(i + 1, a + L[i], b, c) + 10
        res2 = rec(i + 1, a, b + L[i], c) + 10
        res3 = rec(i + 1, a, b, c + L[i]) + 10

        return min(res0, res1, res2, res3)

    print(rec(0, 0, 0, 0))
    return main INF = 1 << 60 1 << 60 INF
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, B, C = map(int, readline().split())
    (*L,) = map(int, read().split())

    @lru_cache(maxsize=None)
    def rec(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

        res0 = rec(i + 1, a, b, c)
        res1 = rec(i + 1, a + L[i], b, c) + 10
        res2 = rec(i + 1, a, b + L[i], c) + 10
        res3 = rec(i + 1, a, b, c + L[i]) + 10

        return min(res0, res1, res2, res3)

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


if __name__ == '__main__':
    main()
