import sys
inf = float('inf')

n, A, B, C, *l = map(int, sys.stdin.read().split())

def cost(a, b, c, cnt, i):
    if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
    return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1))

def main():
    print(cost(0, 0, 0, 0, 0))

if __name__ ==  '__main__':
    main() import sys sys inf = float('inf') inf float('inf') float 'inf' n, A, B, C, *l = map(int, sys.stdin.read().split()) n map(int, sys.stdin.read().split()) map int sys.stdin.read().split() sys.stdin.read().split sys.stdin.read() sys.stdin.read sys.stdin sys stdin read split A B C *l l def cost(a, b, c, cnt, i):
    if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
    return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1)) cost if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
     i == n i n if not (a and b and c): return inf
         not (a and b and c) a and b and c a and b a b c return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3) abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3) 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 10 * (cnt - 3) 10 cnt - 3 cnt 3 return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1)) min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1)) min cost(a, b, c, cnt, i+1) cost a b c cnt i+1 i 1 cost(a+l[i], b, c, cnt+1, i+1) cost a+l[i] a l[i] l i b c cnt+1 cnt 1 i+1 i 1 cost(a, b+l[i], c, cnt+1, i+1) cost a b+l[i] b l[i] l i c cnt+1 cnt 1 i+1 i 1 cost(a, b, c+l[i], cnt+1, i+1) cost a b c+l[i] c l[i] l i cnt+1 cnt 1 i+1 i 1 a a b b c c cnt cnt i i def main():
    print(cost(0, 0, 0, 0, 0)) main print(cost(0, 0, 0, 0, 0)) print cost(0, 0, 0, 0, 0) cost 0 0 0 0 0 if __name__ ==  '__main__':
    main() __name__ ==  '__main__' __name__ '__main__' main() main B, C, *l = map(int, sys.stdin.read().split()) map(int, sys.stdin.read().split()) B def main():
    print(cost(0, 0, 0, 0, 0)) def main():
    print(cost(0, 0, 0, 0, 0)) main n, A, B, C, *l = map(int, sys.stdin.read().split()) map(int, sys.stdin.read().split()) n inf = float('inf') float('inf') inf A, B, C, *l = map(int, sys.stdin.read().split()) map(int, sys.stdin.read().split()) A C, *l = map(int, sys.stdin.read().split()) map(int, sys.stdin.read().split()) C def cost(a, b, c, cnt, i):
    if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
    return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1)) def cost(a, b, c, cnt, i):
    if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
    return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1)) cost
import sys
inf = float('inf')

n, A, B, C, *l = map(int, sys.stdin.read().split())

def cost(a, b, c, cnt, i):
    if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
    return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1))

def main():
    print(cost(0, 0, 0, 0, 0))

if __name__ ==  '__main__':
    main()