from itertools import product

def main():
    N, A, B, C = map(int, input().split())
    L = list(int(input()) for _ in range(N))
    ans = 0
    # A => 0
    # B => 1
    # C => 2
    ans = float('inf')
    for item in product(range(4), repeat=N):
        length_A = 0
        cnt_A = 0
        score_A = 0
        length_B = 0
        cnt_B = 0
        score_B = 0
        length_C = 0
        cnt_C = 0
        score_C = 0
        for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
        if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
        score_A += abs(A - length_A) + 10 * (cnt_A - 1)
        score_B += abs(B - length_B) + 10 * (cnt_B - 1)
        score_C += abs(C - length_C) + 10 * (cnt_C - 1)
        ans = min(ans, score_A + score_B + score_C)
    print(ans)

if __name__ == "__main__":
    main() from itertools import product def main():
    N, A, B, C = map(int, input().split())
    L = list(int(input()) for _ in range(N))
    ans = 0
    # A => 0
    # B => 1
    # C => 2
    ans = float('inf')
    for item in product(range(4), repeat=N):
        length_A = 0
        cnt_A = 0
        score_A = 0
        length_B = 0
        cnt_B = 0
        score_B = 0
        length_C = 0
        cnt_C = 0
        score_C = 0
        for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
        if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
        score_A += abs(A - length_A) + 10 * (cnt_A - 1)
        score_B += abs(B - length_B) + 10 * (cnt_B - 1)
        score_C += abs(C - length_C) + 10 * (cnt_C - 1)
        ans = min(ans, score_A + score_B + score_C)
    print(ans) main N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C L = list(int(input()) for _ in range(N)) L list(int(input()) for _ in range(N)) list int(input()) int input() input ans = 0 ans 0 ans = float('inf') ans float('inf') float 'inf' for item in product(range(4), repeat=N):
        length_A = 0
        cnt_A = 0
        score_A = 0
        length_B = 0
        cnt_B = 0
        score_B = 0
        length_C = 0
        cnt_C = 0
        score_C = 0
        for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
        if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
        score_A += abs(A - length_A) + 10 * (cnt_A - 1)
        score_B += abs(B - length_B) + 10 * (cnt_B - 1)
        score_C += abs(C - length_C) + 10 * (cnt_C - 1)
        ans = min(ans, score_A + score_B + score_C)
     item product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N length_A = 0 length_A 0 cnt_A = 0 cnt_A 0 score_A = 0 score_A 0 length_B = 0 length_B 0 cnt_B = 0 cnt_B 0 score_B = 0 score_B 0 length_C = 0 length_C 0 cnt_C = 0 cnt_C 0 score_C = 0 score_C 0 for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
         i j enumerate(item) enumerate item if j == 0:
                length_A += L[i]
                cnt_A += 1
             j == 0 j 0 length_A += L[i] length_A L[i] L i cnt_A += 1 cnt_A 1 if j == 1:
                length_B += L[i]
                cnt_B += 1
             j == 1 j 1 length_B += L[i] length_B L[i] L i cnt_B += 1 cnt_B 1 if j == 2:
                length_C += L[i]
                cnt_C += 1
         j == 2 j 2 length_C += L[i] length_C L[i] L i cnt_C += 1 cnt_C 1 if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
         cnt_A == 0 or cnt_B == 0 or cnt_C == 0 cnt_A == 0 or cnt_B == 0 cnt_A == 0 cnt_A 0 cnt_B == 0 cnt_B 0 cnt_C == 0 cnt_C 0 continue score_A += abs(A - length_A) + 10 * (cnt_A - 1) score_A abs(A - length_A) + 10 * (cnt_A - 1) abs(A - length_A) abs A - length_A A length_A 10 * (cnt_A - 1) 10 cnt_A - 1 cnt_A 1 score_B += abs(B - length_B) + 10 * (cnt_B - 1) score_B abs(B - length_B) + 10 * (cnt_B - 1) abs(B - length_B) abs B - length_B B length_B 10 * (cnt_B - 1) 10 cnt_B - 1 cnt_B 1 score_C += abs(C - length_C) + 10 * (cnt_C - 1) score_C abs(C - length_C) + 10 * (cnt_C - 1) abs(C - length_C) abs C - length_C C length_C 10 * (cnt_C - 1) 10 cnt_C - 1 cnt_C 1 ans = min(ans, score_A + score_B + score_C) ans min(ans, score_A + score_B + score_C) min ans score_A + score_B + score_C score_A + score_B score_A score_B score_C print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, A, B, C = map(int, input().split())
    L = list(int(input()) for _ in range(N))
    ans = 0
    # A => 0
    # B => 1
    # C => 2
    ans = float('inf')
    for item in product(range(4), repeat=N):
        length_A = 0
        cnt_A = 0
        score_A = 0
        length_B = 0
        cnt_B = 0
        score_B = 0
        length_C = 0
        cnt_C = 0
        score_C = 0
        for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
        if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
        score_A += abs(A - length_A) + 10 * (cnt_A - 1)
        score_B += abs(B - length_B) + 10 * (cnt_B - 1)
        score_C += abs(C - length_C) + 10 * (cnt_C - 1)
        ans = min(ans, score_A + score_B + score_C)
    print(ans) def main():
    N, A, B, C = map(int, input().split())
    L = list(int(input()) for _ in range(N))
    ans = 0
    # A => 0
    # B => 1
    # C => 2
    ans = float('inf')
    for item in product(range(4), repeat=N):
        length_A = 0
        cnt_A = 0
        score_A = 0
        length_B = 0
        cnt_B = 0
        score_B = 0
        length_C = 0
        cnt_C = 0
        score_C = 0
        for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
        if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
        score_A += abs(A - length_A) + 10 * (cnt_A - 1)
        score_B += abs(B - length_B) + 10 * (cnt_B - 1)
        score_C += abs(C - length_C) + 10 * (cnt_C - 1)
        ans = min(ans, score_A + score_B + score_C)
    print(ans) main
from itertools import product

def main():
    N, A, B, C = map(int, input().split())
    L = list(int(input()) for _ in range(N))
    ans = 0
    # A => 0
    # B => 1
    # C => 2
    ans = float('inf')
    for item in product(range(4), repeat=N):
        length_A = 0
        cnt_A = 0
        score_A = 0
        length_B = 0
        cnt_B = 0
        score_B = 0
        length_C = 0
        cnt_C = 0
        score_C = 0
        for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
        if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
        score_A += abs(A - length_A) + 10 * (cnt_A - 1)
        score_B += abs(B - length_B) + 10 * (cnt_B - 1)
        score_C += abs(C - length_C) + 10 * (cnt_C - 1)
        ans = min(ans, score_A + score_B + score_C)
    print(ans)

if __name__ == "__main__":
    main()