import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, a, b, c = map(int, input().split())
l = list(int(input()) for i in range(n))

ans = 0
mpa = mpb = mpc = 0
mp = [0,0,0]
INF = 10**4

groups = [[]*n for _ in range(3)]

def dfs(groups, parent=-1):
    groupa = groups[0]
    groupb = groups[1]
    groupc = groups[2]

    if parent == n-1:
        if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

        if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

        if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

        return mpa+mpb+mpc

    else:
        parent+=1

        addl = [l[parent]]

        adda = dfs([groupa+addl ,groupb, groupc], parent)
        addb = dfs([groupa, groupb+addl, groupc], parent)
        addc = dfs([groupa, groupb, groupc+addl], parent)
        noadd = dfs([groupa,groupb,groupc],parent)

        return min(adda, addb, addc, noadd)

print(dfs(groups)) import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 i in range(n)) l list(int(input()) for i in range(n)) list int(input()) int input() input ans = 0 ans 0 mpa = mpb = mpc = 0 mpa 0 = mpb = mpc = 0 mpb 0 mpc mp = [0,0,0] mp [0,0,0] 0 0 0 INF = 10**4 INF 10**4 10 4 []*n for _ in range(3) for _ in range(3) _ range(3) range 3 for _ in range(3) []*n [] n groups = [[]*n for _ in range(3)] groups [[]*n for _ in range(3)] def dfs(groups, parent=-1):
    groupa = groups[0]
    groupb = groups[1]
    groupc = groups[2]

    if parent == n-1:
        if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

        if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

        if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

        return mpa+mpb+mpc

    else:
        parent+=1

        addl = [l[parent]]

        adda = dfs([groupa+addl ,groupb, groupc], parent)
        addb = dfs([groupa, groupb+addl, groupc], parent)
        addc = dfs([groupa, groupb, groupc+addl], parent)
        noadd = dfs([groupa,groupb,groupc],parent)

        return min(adda, addb, addc, noadd) dfs groupa = groups[0] groupa groups[0] groups 0 groupb = groups[1] groupb groups[1] groups 1 groupc = groups[2] groupc groups[2] groups 2 if parent == n-1:
        if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

        if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

        if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

        return mpa+mpb+mpc

    else:
        parent+=1

        addl = [l[parent]]

        adda = dfs([groupa+addl ,groupb, groupc], parent)
        addb = dfs([groupa, groupb+addl, groupc], parent)
        addc = dfs([groupa, groupb, groupc+addl], parent)
        noadd = dfs([groupa,groupb,groupc],parent)

        return min(adda, addb, addc, noadd) parent == n-1 parent n-1 n 1 if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

         len(groupa) > 0 len(groupa) len groupa 0 if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

         len(groupb) > 0 len(groupb) len groupb 0 if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

         len(groupc) > 0 len(groupc) len groupc 0 return mpa+mpb+mpc mpa+mpb+mpc mpa+mpb mpa mpb mpc parent+=1 parent 1 addl = [l[parent]] addl [l[parent]] l[parent] l parent adda = dfs([groupa+addl ,groupb, groupc], parent) adda dfs([groupa+addl ,groupb, groupc], parent) dfs [groupa+addl ,groupb, groupc] groupa+addl groupa addl groupb groupc parent addb = dfs([groupa, groupb+addl, groupc], parent) addb dfs([groupa, groupb+addl, groupc], parent) dfs [groupa, groupb+addl, groupc] groupa groupb+addl groupb addl groupc parent addc = dfs([groupa, groupb, groupc+addl], parent) addc dfs([groupa, groupb, groupc+addl], parent) dfs [groupa, groupb, groupc+addl] groupa groupb groupc+addl groupc addl parent noadd = dfs([groupa,groupb,groupc],parent) noadd dfs([groupa,groupb,groupc],parent) dfs [groupa,groupb,groupc] groupa groupb groupc parent return min(adda, addb, addc, noadd) min(adda, addb, addc, noadd) min adda addb addc noadd groups groups parent=-1 parent -1 print(dfs(groups)) print dfs(groups) dfs groups mp = [0,0,0] [0,0,0] mp mpa = mpb = mpc = 0 0 mpa ans = 0 0 ans b, c = map(int, input().split()) map(int, input().split()) b l = list(int(input()) for i in range(n)) list(int(input()) for i in range(n)) l a, b, c = map(int, input().split()) map(int, input().split()) a INF = 10**4 10**4 INF input = sys.stdin.readline sys.stdin.readline input groups = [[]*n for _ in range(3)] [[]*n for _ in range(3)] groups c = map(int, input().split()) map(int, input().split()) c mpb = mpc = 0 0 mpb mpc = 0 0 mpc n, a, b, c = map(int, input().split()) map(int, input().split()) n def dfs(groups, parent=-1):
    groupa = groups[0]
    groupb = groups[1]
    groupc = groups[2]

    if parent == n-1:
        if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

        if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

        if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

        return mpa+mpb+mpc

    else:
        parent+=1

        addl = [l[parent]]

        adda = dfs([groupa+addl ,groupb, groupc], parent)
        addb = dfs([groupa, groupb+addl, groupc], parent)
        addc = dfs([groupa, groupb, groupc+addl], parent)
        noadd = dfs([groupa,groupb,groupc],parent)

        return min(adda, addb, addc, noadd) def dfs(groups, parent=-1):
    groupa = groups[0]
    groupb = groups[1]
    groupc = groups[2]

    if parent == n-1:
        if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

        if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

        if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

        return mpa+mpb+mpc

    else:
        parent+=1

        addl = [l[parent]]

        adda = dfs([groupa+addl ,groupb, groupc], parent)
        addb = dfs([groupa, groupb+addl, groupc], parent)
        addc = dfs([groupa, groupb, groupc+addl], parent)
        noadd = dfs([groupa,groupb,groupc],parent)

        return min(adda, addb, addc, noadd) dfs
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, a, b, c = map(int, input().split())
l = list(int(input()) for i in range(n))

ans = 0
mpa = mpb = mpc = 0
mp = [0,0,0]
INF = 10**4

groups = [[]*n for _ in range(3)]

def dfs(groups, parent=-1):
    groupa = groups[0]
    groupb = groups[1]
    groupc = groups[2]

    if parent == n-1:
        if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

        if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

        if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

        return mpa+mpb+mpc

    else:
        parent+=1

        addl = [l[parent]]

        adda = dfs([groupa+addl ,groupb, groupc], parent)
        addb = dfs([groupa, groupb+addl, groupc], parent)
        addc = dfs([groupa, groupb, groupc+addl], parent)
        noadd = dfs([groupa,groupb,groupc],parent)

        return min(adda, addb, addc, noadd)

print(dfs(groups))
