import sys
sys.setrecursionlimit(500000)

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

kumi = []
abcx = ['A', 'B', 'C', 'X']

def dfs(arr: list):
    if len(arr) == N:
        kumi.append(arr[:])
        return
    for k in ['A', 'B', 'C', 'X']:
        arr.append(k)
        dfs(arr)
        arr.pop()

dfs([])

ans = float('inf')
for k in kumi:
    if set(k) & set(['A', 'B', 'C']) != set(['A', 'B', 'C']):
        continue
    tmp = 0
    a = 0
    b = 0
    c = 0
    for i in range(N):
        if k[i] == 'A':
            if a > 0:
                tmp += 10
            a += L[i]
        elif k[i] == 'B':
            if b > 0:
                tmp += 10
            b += L[i]
        elif k[i] == 'C':
            if c > 0:
                tmp += 10
            c += L[i]
    tmp += abs(A-a)
    tmp += abs(B-b)
    tmp += abs(C-c)
    ans = min(ans, tmp)

print(ans) import sys sys sys.setrecursionlimit(500000) sys.setrecursionlimit sys setrecursionlimit 500000 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 i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input L = [int(input()) for i in range(N)] L [int(input()) for i in range(N)] kumi = [] kumi [] abcx = ['A', 'B', 'C', 'X'] abcx ['A', 'B', 'C', 'X'] 'A' 'B' 'C' 'X' def dfs(arr: list):
    if len(arr) == N:
        kumi.append(arr[:])
        return
    for k in ['A', 'B', 'C', 'X']:
        arr.append(k)
        dfs(arr)
        arr.pop() dfs if len(arr) == N:
        kumi.append(arr[:])
        return
     len(arr) == N len(arr) len arr N kumi.append(arr[:]) kumi.append kumi append arr[:] arr : return for k in ['A', 'B', 'C', 'X']:
        arr.append(k)
        dfs(arr)
        arr.pop() k ['A', 'B', 'C', 'X'] 'A' 'B' 'C' 'X' arr.append(k) arr.append arr append k dfs(arr) dfs arr arr.pop() arr.pop arr pop arr: list arr dfs([]) dfs [] ans = float('inf') ans float('inf') float 'inf' for k in kumi:
    if set(k) & set(['A', 'B', 'C']) != set(['A', 'B', 'C']):
        continue
    tmp = 0
    a = 0
    b = 0
    c = 0
    for i in range(N):
        if k[i] == 'A':
            if a > 0:
                tmp += 10
            a += L[i]
        elif k[i] == 'B':
            if b > 0:
                tmp += 10
            b += L[i]
        elif k[i] == 'C':
            if c > 0:
                tmp += 10
            c += L[i]
    tmp += abs(A-a)
    tmp += abs(B-b)
    tmp += abs(C-c)
    ans = min(ans, tmp) k kumi if set(k) & set(['A', 'B', 'C']) != set(['A', 'B', 'C']):
        continue
     set(k) & set(['A', 'B', 'C']) != set(['A', 'B', 'C']) set(k) & set(['A', 'B', 'C']) set(k) set k set(['A', 'B', 'C']) set ['A', 'B', 'C'] 'A' 'B' 'C' set(['A', 'B', 'C']) set ['A', 'B', 'C'] 'A' 'B' 'C' continue tmp = 0 tmp 0 a = 0 a 0 b = 0 b 0 c = 0 c 0 for i in range(N):
        if k[i] == 'A':
            if a > 0:
                tmp += 10
            a += L[i]
        elif k[i] == 'B':
            if b > 0:
                tmp += 10
            b += L[i]
        elif k[i] == 'C':
            if c > 0:
                tmp += 10
            c += L[i]
     i range(N) range N if k[i] == 'A':
            if a > 0:
                tmp += 10
            a += L[i]
        elif k[i] == 'B':
            if b > 0:
                tmp += 10
            b += L[i]
        elif k[i] == 'C':
            if c > 0:
                tmp += 10
            c += L[i]
     k[i] == 'A' k[i] k i 'A' if a > 0:
                tmp += 10
             a > 0 a 0 tmp += 10 tmp 10 a += L[i] a L[i] L i elif k[i] == 'B':
            if b > 0:
                tmp += 10
            b += L[i]
         k[i] == 'B' k[i] k i 'B' if b > 0:
                tmp += 10
             b > 0 b 0 tmp += 10 tmp 10 b += L[i] b L[i] L i elif k[i] == 'C':
            if c > 0:
                tmp += 10
            c += L[i]
     k[i] == 'C' k[i] k i 'C' if c > 0:
                tmp += 10
             c > 0 c 0 tmp += 10 tmp 10 c += L[i] c L[i] L i tmp += abs(A-a) tmp abs(A-a) abs A-a A a tmp += abs(B-b) tmp abs(B-b) abs B-b B b tmp += abs(C-c) tmp abs(C-c) abs C-c C c ans = min(ans, tmp) ans min(ans, tmp) min ans tmp print(ans) print ans N, A, B, C = map(int, input().split()) map(int, input().split()) N tmp += 10 10 tmp tmp += abs(B-b) abs(B-b) tmp A, B, C = map(int, input().split()) map(int, input().split()) A tmp += abs(A-a) abs(A-a) tmp abcx = ['A', 'B', 'C', 'X'] ['A', 'B', 'C', 'X'] abcx ans = min(ans, tmp) min(ans, tmp) ans def dfs(arr: list):
    if len(arr) == N:
        kumi.append(arr[:])
        return
    for k in ['A', 'B', 'C', 'X']:
        arr.append(k)
        dfs(arr)
        arr.pop() def dfs(arr: list):
    if len(arr) == N:
        kumi.append(arr[:])
        return
    for k in ['A', 'B', 'C', 'X']:
        arr.append(k)
        dfs(arr)
        arr.pop() dfs a += L[i] L[i] a c += L[i] L[i] c b += L[i] L[i] b tmp += abs(C-c) abs(C-c) tmp ans = float('inf') float('inf') ans a = 0 0 a b = 0 0 b tmp = 0 0 tmp tmp += 10 10 tmp C = map(int, input().split()) map(int, input().split()) C tmp += 10 10 tmp L = [int(input()) for i in range(N)] [int(input()) for i in range(N)] L kumi = [] [] kumi c = 0 0 c B, C = map(int, input().split()) map(int, input().split()) B
import sys
sys.setrecursionlimit(500000)

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

kumi = []
abcx = ['A', 'B', 'C', 'X']

def dfs(arr: list):
    if len(arr) == N:
        kumi.append(arr[:])
        return
    for k in ['A', 'B', 'C', 'X']:
        arr.append(k)
        dfs(arr)
        arr.pop()

dfs([])

ans = float('inf')
for k in kumi:
    if set(k) & set(['A', 'B', 'C']) != set(['A', 'B', 'C']):
        continue
    tmp = 0
    a = 0
    b = 0
    c = 0
    for i in range(N):
        if k[i] == 'A':
            if a > 0:
                tmp += 10
            a += L[i]
        elif k[i] == 'B':
            if b > 0:
                tmp += 10
            b += L[i]
        elif k[i] == 'C':
            if c > 0:
                tmp += 10
            c += L[i]
    tmp += abs(A-a)
    tmp += abs(B-b)
    tmp += abs(C-c)
    ans = min(ans, tmp)

print(ans)