from itertools import product
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 10 ** 18
for alloc in product(range(4), repeat=N):
    La = 0
    Lb = 0
    Lc = 0
    use_a = 0
    use_b = 0
    use_c = 0
    for i, f in enumerate(alloc):
        if f == 0:
            La += L[i]
            use_a += 1
        elif f == 1:
            Lb += L[i]
            use_b += 1
        elif f == 2:
            Lc += L[i]
            use_c += 1
        else:
            pass

    if not all([use_a, use_b, use_c]):
        continue

    score = 0
    score += 10 * (use_a - 1)
    score += 10 * (use_b - 1)
    score += 10 * (use_c - 1)
    score += abs(A - La)
    score += abs(B - Lb)
    score += abs(C - Lc)
    ans = min(ans, score)

print(ans) from itertools import product import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 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)] ans = 10 ** 18 ans 10 ** 18 10 18 for alloc in product(range(4), repeat=N):
    La = 0
    Lb = 0
    Lc = 0
    use_a = 0
    use_b = 0
    use_c = 0
    for i, f in enumerate(alloc):
        if f == 0:
            La += L[i]
            use_a += 1
        elif f == 1:
            Lb += L[i]
            use_b += 1
        elif f == 2:
            Lc += L[i]
            use_c += 1
        else:
            pass

    if not all([use_a, use_b, use_c]):
        continue

    score = 0
    score += 10 * (use_a - 1)
    score += 10 * (use_b - 1)
    score += 10 * (use_c - 1)
    score += abs(A - La)
    score += abs(B - Lb)
    score += abs(C - Lc)
    ans = min(ans, score) alloc product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N La = 0 La 0 Lb = 0 Lb 0 Lc = 0 Lc 0 use_a = 0 use_a 0 use_b = 0 use_b 0 use_c = 0 use_c 0 for i, f in enumerate(alloc):
        if f == 0:
            La += L[i]
            use_a += 1
        elif f == 1:
            Lb += L[i]
            use_b += 1
        elif f == 2:
            Lc += L[i]
            use_c += 1
        else:
            pass

     i f enumerate(alloc) enumerate alloc if f == 0:
            La += L[i]
            use_a += 1
        elif f == 1:
            Lb += L[i]
            use_b += 1
        elif f == 2:
            Lc += L[i]
            use_c += 1
        else:
            pass

     f == 0 f 0 La += L[i] La L[i] L i use_a += 1 use_a 1 elif f == 1:
            Lb += L[i]
            use_b += 1
         f == 1 f 1 Lb += L[i] Lb L[i] L i use_b += 1 use_b 1 elif f == 2:
            Lc += L[i]
            use_c += 1
         f == 2 f 2 Lc += L[i] Lc L[i] L i use_c += 1 use_c 1 if not all([use_a, use_b, use_c]):
        continue

     not all([use_a, use_b, use_c]) all([use_a, use_b, use_c]) all [use_a, use_b, use_c] use_a use_b use_c continue score = 0 score 0 score += 10 * (use_a - 1) score 10 * (use_a - 1) 10 use_a - 1 use_a 1 score += 10 * (use_b - 1) score 10 * (use_b - 1) 10 use_b - 1 use_b 1 score += 10 * (use_c - 1) score 10 * (use_c - 1) 10 use_c - 1 use_c 1 score += abs(A - La) score abs(A - La) abs A - La A La score += abs(B - Lb) score abs(B - Lb) abs B - Lb B Lb score += abs(C - Lc) score abs(C - Lc) abs C - Lc C Lc ans = min(ans, score) ans min(ans, score) min ans score print(ans) print ans score += 10 * (use_c - 1) 10 * (use_c - 1) score use_a += 1 1 use_a Lc += L[i] L[i] Lc La += L[i] L[i] La score += 10 * (use_b - 1) 10 * (use_b - 1) score use_b = 0 0 use_b C = map(int, input().split()) map(int, input().split()) C ans = min(ans, score) min(ans, score) ans La = 0 0 La ans = 10 ** 18 10 ** 18 ans B, C = map(int, input().split()) map(int, input().split()) B input = sys.stdin.buffer.readline sys.stdin.buffer.readline input N, A, B, C = map(int, input().split()) map(int, input().split()) N A, B, C = map(int, input().split()) map(int, input().split()) A score = 0 0 score score += abs(C - Lc) abs(C - Lc) score use_c += 1 1 use_c use_b += 1 1 use_b use_c = 0 0 use_c score += abs(B - Lb) abs(B - Lb) score Lc = 0 0 Lc score += abs(A - La) abs(A - La) score L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L score += 10 * (use_a - 1) 10 * (use_a - 1) score Lb += L[i] L[i] Lb use_a = 0 0 use_a Lb = 0 0 Lb
from itertools import product
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 10 ** 18
for alloc in product(range(4), repeat=N):
    La = 0
    Lb = 0
    Lc = 0
    use_a = 0
    use_b = 0
    use_c = 0
    for i, f in enumerate(alloc):
        if f == 0:
            La += L[i]
            use_a += 1
        elif f == 1:
            Lb += L[i]
            use_b += 1
        elif f == 2:
            Lc += L[i]
            use_c += 1
        else:
            pass

    if not all([use_a, use_b, use_c]):
        continue

    score = 0
    score += 10 * (use_a - 1)
    score += 10 * (use_b - 1)
    score += 10 * (use_c - 1)
    score += abs(A - La)
    score += abs(B - Lb)
    score += abs(C - Lc)
    ans = min(ans, score)

print(ans)