import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    n,*abc=MI()
    abc.sort()
    a,b,c=abc
    dp={(0,0,0):0}
    for _ in range(n):
        l=II()
        ndp={}
        for xyz,s in dp.items():
            ndp.setdefault(xyz,inf)
            ndp[xyz]=min(ndp[xyz],s)
            for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
            dp=ndp

    ans=inf
    for (x,y,z),s in dp.items():
        if x*y*z==0:continue
        cur=abs(x-a)+abs(y-b)+abs(z-c)+s
        ans=min(ans,cur)

    print(ans)

main() import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 int1 = lambda x: int(x) - 1 int1 lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x p2D = lambda x: print(*x, sep="\n") p2D lambda x: print(*x, sep="\n") print(*x, sep="\n") print *x x sep="\n" sep "\n" x def II(): return int(sys.stdin.readline()) II def MI(): return map(int, sys.stdin.readline().split()) MI def LI(): return list(map(int, sys.stdin.readline().split())) LI LI() for _ in range(rows_number) for _ in range(rows_number) _ range(rows_number) range rows_number for _ in range(rows_number) LI() LI def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI rows_number rows_number def SI(): return sys.stdin.readline()[:-1] SI def main():
    inf=10**9
    n,*abc=MI()
    abc.sort()
    a,b,c=abc
    dp={(0,0,0):0}
    for _ in range(n):
        l=II()
        ndp={}
        for xyz,s in dp.items():
            ndp.setdefault(xyz,inf)
            ndp[xyz]=min(ndp[xyz],s)
            for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
            dp=ndp

    ans=inf
    for (x,y,z),s in dp.items():
        if x*y*z==0:continue
        cur=abs(x-a)+abs(y-b)+abs(z-c)+s
        ans=min(ans,cur)

    print(ans) main inf=10**9 inf 10**9 10 9 n,*abc=MI() n MI() MI *abc abc abc.sort() abc.sort abc sort a,b,c=abc a abc b c dp={(0,0,0):0} dp {(0,0,0):0} (0,0,0) (0,0,0) 0 0 0 0 for _ in range(n):
        l=II()
        ndp={}
        for xyz,s in dp.items():
            ndp.setdefault(xyz,inf)
            ndp[xyz]=min(ndp[xyz],s)
            for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
            dp=ndp

     _ range(n) range n l=II() l II() II ndp={} ndp {} for xyz,s in dp.items():
            ndp.setdefault(xyz,inf)
            ndp[xyz]=min(ndp[xyz],s)
            for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
            dp=ndp

     xyz s dp.items() dp.items dp items ndp.setdefault(xyz,inf) ndp.setdefault ndp setdefault xyz inf ndp[xyz]=min(ndp[xyz],s) ndp[xyz] ndp xyz min(ndp[xyz],s) min ndp[xyz] ndp xyz s for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
             i range(3) range 3 nx=list(xyz) nx list(xyz) list xyz ns=s+10 if nx[i] else s ns s+10 if nx[i] else s nx[i] nx i s+10 s 10 s nx[i]+=l nx[i] nx i l t=tuple(sorted(nx)) t tuple(sorted(nx)) tuple sorted(nx) sorted nx ndp.setdefault(t,inf) ndp.setdefault ndp setdefault t inf ndp[t]=min(ndp[t],ns) ndp[t] ndp t min(ndp[t],ns) min ndp[t] ndp t ns dp=ndp dp ndp ans=inf ans inf for (x,y,z),s in dp.items():
        if x*y*z==0:continue
        cur=abs(x-a)+abs(y-b)+abs(z-c)+s
        ans=min(ans,cur)

     (x,y,z) x y z s dp.items() dp.items dp items if x*y*z==0:continue
         x*y*z==0 x*y*z x*y x y z 0 cur=abs(x-a)+abs(y-b)+abs(z-c)+s cur abs(x-a)+abs(y-b)+abs(z-c)+s abs(x-a)+abs(y-b)+abs(z-c) abs(x-a)+abs(y-b) abs(x-a) abs x-a x a abs(y-b) abs y-b y b abs(z-c) abs z-c z c s ans=min(ans,cur) ans min(ans,cur) min ans cur print(ans) print ans main() main int1 = lambda x: int(x) - 1 lambda x: int(x) - 1 int1 def MI(): return map(int, sys.stdin.readline().split()) def MI(): return map(int, sys.stdin.readline().split()) MI def main():
    inf=10**9
    n,*abc=MI()
    abc.sort()
    a,b,c=abc
    dp={(0,0,0):0}
    for _ in range(n):
        l=II()
        ndp={}
        for xyz,s in dp.items():
            ndp.setdefault(xyz,inf)
            ndp[xyz]=min(ndp[xyz],s)
            for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
            dp=ndp

    ans=inf
    for (x,y,z),s in dp.items():
        if x*y*z==0:continue
        cur=abs(x-a)+abs(y-b)+abs(z-c)+s
        ans=min(ans,cur)

    print(ans) def main():
    inf=10**9
    n,*abc=MI()
    abc.sort()
    a,b,c=abc
    dp={(0,0,0):0}
    for _ in range(n):
        l=II()
        ndp={}
        for xyz,s in dp.items():
            ndp.setdefault(xyz,inf)
            ndp[xyz]=min(ndp[xyz],s)
            for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
            dp=ndp

    ans=inf
    for (x,y,z),s in dp.items():
        if x*y*z==0:continue
        cur=abs(x-a)+abs(y-b)+abs(z-c)+s
        ans=min(ans,cur)

    print(ans) main def SI(): return sys.stdin.readline()[:-1] def SI(): return sys.stdin.readline()[:-1] SI def II(): return int(sys.stdin.readline()) def II(): return int(sys.stdin.readline()) II def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI p2D = lambda x: print(*x, sep="\n") lambda x: print(*x, sep="\n") p2D def LI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) LI
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    n,*abc=MI()
    abc.sort()
    a,b,c=abc
    dp={(0,0,0):0}
    for _ in range(n):
        l=II()
        ndp={}
        for xyz,s in dp.items():
            ndp.setdefault(xyz,inf)
            ndp[xyz]=min(ndp[xyz],s)
            for i in range(3):
                nx=list(xyz)
                ns=s+10 if nx[i] else s
                nx[i]+=l
                t=tuple(sorted(nx))
                ndp.setdefault(t,inf)
                ndp[t]=min(ndp[t],ns)
            dp=ndp

    ans=inf
    for (x,y,z),s in dp.items():
        if x*y*z==0:continue
        cur=abs(x-a)+abs(y-b)+abs(z-c)+s
        ans=min(ans,cur)

    print(ans)

main()