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()

# def main():
  

# # main()
# print(main())

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

def f(lst,ind):
  global answer
  if ind==n:
    ac=lst.count(1)
    bc=lst.count(2)
    cc=lst.count(3)

    if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

    _a=_b=_c=0
    for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

    sm=0
    sm+=max(0,ac-1)*10
    sm+=max(0,bc-1)*10
    sm+=max(0,cc-1)*10
    sm+=abs(a-_a)
    sm+=abs(b-_b)
    sm+=abs(c-_c)

    return min(answer,sm)

  else:
    for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

  return answer

lst=[-1]*n
print(f(lst,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()

# def main():
  

# # main()
# print(main()) 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)] answer=inf answer inf def f(lst,ind):
  global answer
  if ind==n:
    ac=lst.count(1)
    bc=lst.count(2)
    cc=lst.count(3)

    if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

    _a=_b=_c=0
    for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

    sm=0
    sm+=max(0,ac-1)*10
    sm+=max(0,bc-1)*10
    sm+=max(0,cc-1)*10
    sm+=abs(a-_a)
    sm+=abs(b-_b)
    sm+=abs(c-_c)

    return min(answer,sm)

  else:
    for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

  return answer f global answer if ind==n:
    ac=lst.count(1)
    bc=lst.count(2)
    cc=lst.count(3)

    if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

    _a=_b=_c=0
    for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

    sm=0
    sm+=max(0,ac-1)*10
    sm+=max(0,bc-1)*10
    sm+=max(0,cc-1)*10
    sm+=abs(a-_a)
    sm+=abs(b-_b)
    sm+=abs(c-_c)

    return min(answer,sm)

  else:
    for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

   ind==n ind n ac=lst.count(1) ac lst.count(1) lst.count lst count 1 bc=lst.count(2) bc lst.count(2) lst.count lst count 2 cc=lst.count(3) cc lst.count(3) lst.count lst count 3 if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

     ac==0 or bc==0 or cc==0 ac==0 or bc==0 ac==0 ac 0 bc==0 bc 0 cc==0 cc 0 return min(answer,inf) min(answer,inf) min answer inf _a=_b=_c=0 _a 0 =_b=_c=0 _b 0 _c for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

     i x enumerate(lst) enumerate lst if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

     x==1 x 1 _a+=l[i] _a l[i] l i elif x==2:
        _b+=l[i]
       x==2 x 2 _b+=l[i] _b l[i] l i elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

     x==3 x 3 _c+=l[i] _c l[i] l i sm=0 sm 0 sm+=max(0,ac-1)*10 sm max(0,ac-1)*10 max(0,ac-1) max 0 ac-1 ac 1 10 sm+=max(0,bc-1)*10 sm max(0,bc-1)*10 max(0,bc-1) max 0 bc-1 bc 1 10 sm+=max(0,cc-1)*10 sm max(0,cc-1)*10 max(0,cc-1) max 0 cc-1 cc 1 10 sm+=abs(a-_a) sm abs(a-_a) abs a-_a a _a sm+=abs(b-_b) sm abs(b-_b) abs b-_b b _b sm+=abs(c-_c) sm abs(c-_c) abs c-_c c _c return min(answer,sm) min(answer,sm) min answer sm for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

   i range(4) range 4 lst[ind]=i lst[ind] lst ind i answer=min(answer,f(lst,ind+1)) answer min(answer,f(lst,ind+1)) min answer f(lst,ind+1) f lst ind+1 ind 1 return answer answer lst lst ind ind lst=[-1]*n lst [-1]*n [-1] -1 n print(f(lst,0)) print f(lst,0) f lst 0 n,a,b,c=LI() LI() n def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS inf=10**20 10**20 inf 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 c=LI() LI() c mod=10**9+7 10**9+7 mod lst=[-1]*n [-1]*n lst def S(): return input()

# def main():
  

# # main()
# print(main()) def S(): return input()

# def main():
  

# # main()
# print(main()) S a,b,c=LI() LI() a def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I l=[I() for _ in range(n)] [I() for _ in range(n)] l b,c=LI() LI() b def f(lst,ind):
  global answer
  if ind==n:
    ac=lst.count(1)
    bc=lst.count(2)
    cc=lst.count(3)

    if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

    _a=_b=_c=0
    for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

    sm=0
    sm+=max(0,ac-1)*10
    sm+=max(0,bc-1)*10
    sm+=max(0,cc-1)*10
    sm+=abs(a-_a)
    sm+=abs(b-_b)
    sm+=abs(c-_c)

    return min(answer,sm)

  else:
    for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

  return answer def f(lst,ind):
  global answer
  if ind==n:
    ac=lst.count(1)
    bc=lst.count(2)
    cc=lst.count(3)

    if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

    _a=_b=_c=0
    for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

    sm=0
    sm+=max(0,ac-1)*10
    sm+=max(0,bc-1)*10
    sm+=max(0,cc-1)*10
    sm+=abs(a-_a)
    sm+=abs(b-_b)
    sm+=abs(c-_c)

    return min(answer,sm)

  else:
    for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

  return answer f def F(): return float(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) F 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 answer=inf inf answer
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()

# def main():
  

# # main()
# print(main())

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

def f(lst,ind):
  global answer
  if ind==n:
    ac=lst.count(1)
    bc=lst.count(2)
    cc=lst.count(3)

    if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

    _a=_b=_c=0
    for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

    sm=0
    sm+=max(0,ac-1)*10
    sm+=max(0,bc-1)*10
    sm+=max(0,cc-1)*10
    sm+=abs(a-_a)
    sm+=abs(b-_b)
    sm+=abs(c-_c)

    return min(answer,sm)

  else:
    for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

  return answer

lst=[-1]*n
print(f(lst,0))
