import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

n,a,b,c=LI()
l=[I() for _ in range(n)]

def dfs(cnt,aa,bb,cc):
  if cnt==n:
    if aa==0 or bb==0 or cc==0:
      return inf
    return abs(aa-a)+abs(bb-b)+abs(cc-c)-30

  aaa=dfs(cnt+1,aa+l[cnt],bb,cc)+10
  bbb=dfs(cnt+1,aa,bb+l[cnt],cc)+10
  ccc=dfs(cnt+1,aa,bb,cc+l[cnt])+10
  ddd=dfs(cnt+1,aa,bb,cc)
  return min(aaa,bbb,ccc,ddd)

print(dfs(0,0,0,0)) import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy math itertools fractions heapq collections bisect sys queue copy sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 inf=10**20 inf 10**20 10 20 mod=10**9+7 mod 10**9+7 10**9 10 9 7 dd=[(-1,0),(0,1),(1,0),(0,-1)] dd [(-1,0),(0,1),(1,0),(0,-1)] (-1,0) -1 0 (0,1) 0 1 (1,0) 1 0 (0,-1) 0 -1 ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] ddn [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] (-1,0) -1 0 (-1,1) -1 1 (0,1) 0 1 (1,1) 1 1 (1,0) 1 0 (1,-1) 1 -1 (0,-1) 0 -1 (-1,-1) -1 -1 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()] LI def I(): return int(sys.stdin.readline()) I def F(): return float(sys.stdin.readline()) F def LS(): return sys.stdin.readline().split() LS def S(): return input() S n,a,b,c=LI() n LI() LI a b c I() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) I() I l=[I() for _ in range(n)] l [I() for _ in range(n)] def dfs(cnt,aa,bb,cc):
  if cnt==n:
    if aa==0 or bb==0 or cc==0:
      return inf
    return abs(aa-a)+abs(bb-b)+abs(cc-c)-30

  aaa=dfs(cnt+1,aa+l[cnt],bb,cc)+10
  bbb=dfs(cnt+1,aa,bb+l[cnt],cc)+10
  ccc=dfs(cnt+1,aa,bb,cc+l[cnt])+10
  ddd=dfs(cnt+1,aa,bb,cc)
  return min(aaa,bbb,ccc,ddd) dfs if cnt==n:
    if aa==0 or bb==0 or cc==0:
      return inf
    return abs(aa-a)+abs(bb-b)+abs(cc-c)-30

   cnt==n cnt n if aa==0 or bb==0 or cc==0:
      return inf
     aa==0 or bb==0 or cc==0 aa==0 or bb==0 aa==0 aa 0 bb==0 bb 0 cc==0 cc 0 return inf inf return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 abs(aa-a)+abs(bb-b)+abs(cc-c)-30 abs(aa-a)+abs(bb-b)+abs(cc-c) abs(aa-a)+abs(bb-b) abs(aa-a) abs aa-a aa a abs(bb-b) abs bb-b bb b abs(cc-c) abs cc-c cc c 30 aaa=dfs(cnt+1,aa+l[cnt],bb,cc)+10 aaa dfs(cnt+1,aa+l[cnt],bb,cc)+10 dfs(cnt+1,aa+l[cnt],bb,cc) dfs cnt+1 cnt 1 aa+l[cnt] aa l[cnt] l cnt bb cc 10 bbb=dfs(cnt+1,aa,bb+l[cnt],cc)+10 bbb dfs(cnt+1,aa,bb+l[cnt],cc)+10 dfs(cnt+1,aa,bb+l[cnt],cc) dfs cnt+1 cnt 1 aa bb+l[cnt] bb l[cnt] l cnt cc 10 ccc=dfs(cnt+1,aa,bb,cc+l[cnt])+10 ccc dfs(cnt+1,aa,bb,cc+l[cnt])+10 dfs(cnt+1,aa,bb,cc+l[cnt]) dfs cnt+1 cnt 1 aa bb cc+l[cnt] cc l[cnt] l cnt 10 ddd=dfs(cnt+1,aa,bb,cc) ddd dfs(cnt+1,aa,bb,cc) dfs cnt+1 cnt 1 aa bb cc return min(aaa,bbb,ccc,ddd) min(aaa,bbb,ccc,ddd) min aaa bbb ccc ddd cnt cnt aa aa bb bb cc cc print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 inf=10**20 10**20 inf def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS def S(): return input() def S(): return input() S c=LI() LI() c mod=10**9+7 10**9+7 mod def F(): return float(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) F b,c=LI() LI() b def dfs(cnt,aa,bb,cc):
  if cnt==n:
    if aa==0 or bb==0 or cc==0:
      return inf
    return abs(aa-a)+abs(bb-b)+abs(cc-c)-30

  aaa=dfs(cnt+1,aa+l[cnt],bb,cc)+10
  bbb=dfs(cnt+1,aa,bb+l[cnt],cc)+10
  ccc=dfs(cnt+1,aa,bb,cc+l[cnt])+10
  ddd=dfs(cnt+1,aa,bb,cc)
  return min(aaa,bbb,ccc,ddd) def dfs(cnt,aa,bb,cc):
  if cnt==n:
    if aa==0 or bb==0 or cc==0:
      return inf
    return abs(aa-a)+abs(bb-b)+abs(cc-c)-30

  aaa=dfs(cnt+1,aa+l[cnt],bb,cc)+10
  bbb=dfs(cnt+1,aa,bb+l[cnt],cc)+10
  ccc=dfs(cnt+1,aa,bb,cc+l[cnt])+10
  ddd=dfs(cnt+1,aa,bb,cc)
  return min(aaa,bbb,ccc,ddd) dfs def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I dd=[(-1,0),(0,1),(1,0),(0,-1)] [(-1,0),(0,1),(1,0),(0,-1)] dd ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] ddn l=[I() for _ in range(n)] [I() for _ in range(n)] l n,a,b,c=LI() LI() n def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()] def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()] LI a,b,c=LI() LI() a
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

n,a,b,c=LI()
l=[I() for _ in range(n)]

def dfs(cnt,aa,bb,cc):
  if cnt==n:
    if aa==0 or bb==0 or cc==0:
      return inf
    return abs(aa-a)+abs(bb-b)+abs(cc-c)-30

  aaa=dfs(cnt+1,aa+l[cnt],bb,cc)+10
  bbb=dfs(cnt+1,aa,bb+l[cnt],cc)+10
  ccc=dfs(cnt+1,aa,bb,cc+l[cnt])+10
  ddd=dfs(cnt+1,aa,bb,cc)
  return min(aaa,bbb,ccc,ddd)

print(dfs(0,0,0,0))
