import sys
input = lambda: sys.stdin.readline().rstrip()

N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs():
    stack = [(0,0,0,0,0)]
    ans = float("inf")

    while stack:
        current, c_a, c_b, c_c, score = stack.pop()

        if current == N:
            if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
            continue

        stack.append((current+1, c_a, c_b, c_c, score))
        stack.append((current+1, c_a+l[current], c_b, c_c, score+10))
        stack.append((current+1, c_a, c_b+l[current], c_c, score+10))
        stack.append((current+1, c_a, c_b, c_c+l[current], score+10))

    return ans
print(dfs()) import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip N,A,B,C = map(int, input().split()) N 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)] def dfs():
    stack = [(0,0,0,0,0)]
    ans = float("inf")

    while stack:
        current, c_a, c_b, c_c, score = stack.pop()

        if current == N:
            if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
            continue

        stack.append((current+1, c_a, c_b, c_c, score))
        stack.append((current+1, c_a+l[current], c_b, c_c, score+10))
        stack.append((current+1, c_a, c_b+l[current], c_c, score+10))
        stack.append((current+1, c_a, c_b, c_c+l[current], score+10))

    return ans dfs stack = [(0,0,0,0,0)] stack [(0,0,0,0,0)] (0,0,0,0,0) 0 0 0 0 0 ans = float("inf") ans float("inf") float "inf" while stack:
        current, c_a, c_b, c_c, score = stack.pop()

        if current == N:
            if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
            continue

        stack.append((current+1, c_a, c_b, c_c, score))
        stack.append((current+1, c_a+l[current], c_b, c_c, score+10))
        stack.append((current+1, c_a, c_b+l[current], c_c, score+10))
        stack.append((current+1, c_a, c_b, c_c+l[current], score+10))

     stack current, c_a, c_b, c_c, score = stack.pop() current stack.pop() stack.pop stack pop c_a c_b c_c score if current == N:
            if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
            continue

         current == N current N if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
             c_a > 0 and c_b > 0 and c_c > 0 c_a > 0 and c_b > 0 c_a > 0 c_a 0 c_b > 0 c_b 0 c_c > 0 c_c 0 ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30) ans min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30) min ans abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30 abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score abs(A - c_a) + abs(B - c_b) + abs(C - c_c) abs(A - c_a) + abs(B - c_b) abs(A - c_a) abs A - c_a A c_a abs(B - c_b) abs B - c_b B c_b abs(C - c_c) abs C - c_c C c_c score 30 continue stack.append((current+1, c_a, c_b, c_c, score)) stack.append stack append (current+1, c_a, c_b, c_c, score) current+1 current 1 c_a c_b c_c score stack.append((current+1, c_a+l[current], c_b, c_c, score+10)) stack.append stack append (current+1, c_a+l[current], c_b, c_c, score+10) current+1 current 1 c_a+l[current] c_a l[current] l current c_b c_c score+10 score 10 stack.append((current+1, c_a, c_b+l[current], c_c, score+10)) stack.append stack append (current+1, c_a, c_b+l[current], c_c, score+10) current+1 current 1 c_a c_b+l[current] c_b l[current] l current c_c score+10 score 10 stack.append((current+1, c_a, c_b, c_c+l[current], score+10)) stack.append stack append (current+1, c_a, c_b, c_c+l[current], score+10) current+1 current 1 c_a c_b c_c+l[current] c_c l[current] l current score+10 score 10 return ans ans print(dfs()) print dfs() dfs B,C = map(int, input().split()) map(int, input().split()) B N,A,B,C = map(int, input().split()) map(int, input().split()) N def dfs():
    stack = [(0,0,0,0,0)]
    ans = float("inf")

    while stack:
        current, c_a, c_b, c_c, score = stack.pop()

        if current == N:
            if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
            continue

        stack.append((current+1, c_a, c_b, c_c, score))
        stack.append((current+1, c_a+l[current], c_b, c_c, score+10))
        stack.append((current+1, c_a, c_b+l[current], c_c, score+10))
        stack.append((current+1, c_a, c_b, c_c+l[current], score+10))

    return ans def dfs():
    stack = [(0,0,0,0,0)]
    ans = float("inf")

    while stack:
        current, c_a, c_b, c_c, score = stack.pop()

        if current == N:
            if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
            continue

        stack.append((current+1, c_a, c_b, c_c, score))
        stack.append((current+1, c_a+l[current], c_b, c_c, score+10))
        stack.append((current+1, c_a, c_b+l[current], c_c, score+10))
        stack.append((current+1, c_a, c_b, c_c+l[current], score+10))

    return ans dfs C = map(int, input().split()) map(int, input().split()) C input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l A,B,C = map(int, input().split()) map(int, input().split()) A
import sys
input = lambda: sys.stdin.readline().rstrip()

N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs():
    stack = [(0,0,0,0,0)]
    ans = float("inf")

    while stack:
        current, c_a, c_b, c_c, score = stack.pop()

        if current == N:
            if c_a > 0 and c_b > 0 and c_c > 0:
                ans = min(ans, abs(A - c_a) + abs(B - c_b) + abs(C - c_c) + score - 30)
            continue

        stack.append((current+1, c_a, c_b, c_c, score))
        stack.append((current+1, c_a+l[current], c_b, c_c, score+10))
        stack.append((current+1, c_a, c_b+l[current], c_c, score+10))
        stack.append((current+1, c_a, c_b, c_c+l[current], score+10))

    return ans
print(dfs())