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

ans = 10 ** 10

# 4bit search
for i in range(4**N):
    mask = i
    NowCost = 0
    Group0 = []
    Group1 = []
    Group2 = []
    NonGroup = []
    for j in range(N-1, -1, -1):
        if mask % 4 == 0:
            Group0.append(L[j])
            mask //= 4
        elif mask % 4 == 1:
            Group1.append(L[j])
            mask //= 4
        elif mask % 4 == 2:
            Group2.append(L[j])
            mask //= 4
        else:
            NonGroup.append(L[j])
            mask //= 4
    if len(Group0) == 0 or len(Group1) == 0 or len(Group2) == 0:
        continue
    NowCost += 10 * (len(Group0) - 1)
    LengthGroup0 = sum(Group0)
    NowCost += 10 * (len(Group1) - 1)
    LengthGroup1 = sum(Group1)
    NowCost += 10 * (len(Group2) - 1)
    LengthGroup2 = sum(Group2)
    NowCost += abs(A - LengthGroup0)
    NowCost += abs(B - LengthGroup1)
    NowCost += abs(C - LengthGroup2)
    ans = min(ans, NowCost)
print(ans) 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 ** 10 ans 10 ** 10 10 10 for i in range(4**N):
    mask = i
    NowCost = 0
    Group0 = []
    Group1 = []
    Group2 = []
    NonGroup = []
    for j in range(N-1, -1, -1):
        if mask % 4 == 0:
            Group0.append(L[j])
            mask //= 4
        elif mask % 4 == 1:
            Group1.append(L[j])
            mask //= 4
        elif mask % 4 == 2:
            Group2.append(L[j])
            mask //= 4
        else:
            NonGroup.append(L[j])
            mask //= 4
    if len(Group0) == 0 or len(Group1) == 0 or len(Group2) == 0:
        continue
    NowCost += 10 * (len(Group0) - 1)
    LengthGroup0 = sum(Group0)
    NowCost += 10 * (len(Group1) - 1)
    LengthGroup1 = sum(Group1)
    NowCost += 10 * (len(Group2) - 1)
    LengthGroup2 = sum(Group2)
    NowCost += abs(A - LengthGroup0)
    NowCost += abs(B - LengthGroup1)
    NowCost += abs(C - LengthGroup2)
    ans = min(ans, NowCost) i range(4**N) range 4**N 4 N mask = i mask i NowCost = 0 NowCost 0 Group0 = [] Group0 [] Group1 = [] Group1 [] Group2 = [] Group2 [] NonGroup = [] NonGroup [] for j in range(N-1, -1, -1):
        if mask % 4 == 0:
            Group0.append(L[j])
            mask //= 4
        elif mask % 4 == 1:
            Group1.append(L[j])
            mask //= 4
        elif mask % 4 == 2:
            Group2.append(L[j])
            mask //= 4
        else:
            NonGroup.append(L[j])
            mask //= 4
     j range(N-1, -1, -1) range N-1 N 1 -1 -1 if mask % 4 == 0:
            Group0.append(L[j])
            mask //= 4
        elif mask % 4 == 1:
            Group1.append(L[j])
            mask //= 4
        elif mask % 4 == 2:
            Group2.append(L[j])
            mask //= 4
        else:
            NonGroup.append(L[j])
            mask //= 4
     mask % 4 == 0 mask % 4 mask 4 0 Group0.append(L[j]) Group0.append Group0 append L[j] L j mask //= 4 mask 4 elif mask % 4 == 1:
            Group1.append(L[j])
            mask //= 4
         mask % 4 == 1 mask % 4 mask 4 1 Group1.append(L[j]) Group1.append Group1 append L[j] L j mask //= 4 mask 4 elif mask % 4 == 2:
            Group2.append(L[j])
            mask //= 4
         mask % 4 == 2 mask % 4 mask 4 2 Group2.append(L[j]) Group2.append Group2 append L[j] L j mask //= 4 mask 4 NonGroup.append(L[j]) NonGroup.append NonGroup append L[j] L j mask //= 4 mask 4 if len(Group0) == 0 or len(Group1) == 0 or len(Group2) == 0:
        continue
     len(Group0) == 0 or len(Group1) == 0 or len(Group2) == 0 len(Group0) == 0 or len(Group1) == 0 len(Group0) == 0 len(Group0) len Group0 0 len(Group1) == 0 len(Group1) len Group1 0 len(Group2) == 0 len(Group2) len Group2 0 continue NowCost += 10 * (len(Group0) - 1) NowCost 10 * (len(Group0) - 1) 10 len(Group0) - 1 len(Group0) len Group0 1 LengthGroup0 = sum(Group0) LengthGroup0 sum(Group0) sum Group0 NowCost += 10 * (len(Group1) - 1) NowCost 10 * (len(Group1) - 1) 10 len(Group1) - 1 len(Group1) len Group1 1 LengthGroup1 = sum(Group1) LengthGroup1 sum(Group1) sum Group1 NowCost += 10 * (len(Group2) - 1) NowCost 10 * (len(Group2) - 1) 10 len(Group2) - 1 len(Group2) len Group2 1 LengthGroup2 = sum(Group2) LengthGroup2 sum(Group2) sum Group2 NowCost += abs(A - LengthGroup0) NowCost abs(A - LengthGroup0) abs A - LengthGroup0 A LengthGroup0 NowCost += abs(B - LengthGroup1) NowCost abs(B - LengthGroup1) abs B - LengthGroup1 B LengthGroup1 NowCost += abs(C - LengthGroup2) NowCost abs(C - LengthGroup2) abs C - LengthGroup2 C LengthGroup2 ans = min(ans, NowCost) ans min(ans, NowCost) min ans NowCost print(ans) print ans B, C = map(int, input().split()) map(int, input().split()) B NonGroup = [] [] NonGroup mask //= 4 4 mask ans = 10 ** 10 10 ** 10 ans Group2 = [] [] Group2 NowCost += abs(C - LengthGroup2) abs(C - LengthGroup2) NowCost NowCost += 10 * (len(Group2) - 1) 10 * (len(Group2) - 1) NowCost mask = i i mask 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 C = map(int, input().split()) map(int, input().split()) C Group1 = [] [] Group1 NowCost += 10 * (len(Group1) - 1) 10 * (len(Group1) - 1) NowCost L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L NowCost = 0 0 NowCost Group0 = [] [] Group0 mask //= 4 4 mask LengthGroup1 = sum(Group1) sum(Group1) LengthGroup1 mask //= 4 4 mask ans = min(ans, NowCost) min(ans, NowCost) ans mask //= 4 4 mask NowCost += abs(A - LengthGroup0) abs(A - LengthGroup0) NowCost NowCost += abs(B - LengthGroup1) abs(B - LengthGroup1) NowCost LengthGroup2 = sum(Group2) sum(Group2) LengthGroup2 NowCost += 10 * (len(Group0) - 1) 10 * (len(Group0) - 1) NowCost LengthGroup0 = sum(Group0) sum(Group0) LengthGroup0
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = 10 ** 10

# 4bit search
for i in range(4**N):
    mask = i
    NowCost = 0
    Group0 = []
    Group1 = []
    Group2 = []
    NonGroup = []
    for j in range(N-1, -1, -1):
        if mask % 4 == 0:
            Group0.append(L[j])
            mask //= 4
        elif mask % 4 == 1:
            Group1.append(L[j])
            mask //= 4
        elif mask % 4 == 2:
            Group2.append(L[j])
            mask //= 4
        else:
            NonGroup.append(L[j])
            mask //= 4
    if len(Group0) == 0 or len(Group1) == 0 or len(Group2) == 0:
        continue
    NowCost += 10 * (len(Group0) - 1)
    LengthGroup0 = sum(Group0)
    NowCost += 10 * (len(Group1) - 1)
    LengthGroup1 = sum(Group1)
    NowCost += 10 * (len(Group2) - 1)
    LengthGroup2 = sum(Group2)
    NowCost += abs(A - LengthGroup0)
    NowCost += abs(B - LengthGroup1)
    NowCost += abs(C - LengthGroup2)
    ans = min(ans, NowCost)
print(ans)
