import sys
def input():
  return sys.stdin.readline().rstrip()

def rec(i,a,b,c):
  if i==N:
    if a==0 or b==0 or c==0:
      return 10**12
    return abs(a-A)+abs(b-B)+abs(c-C)

  res=rec(i+1,a,b,c);

  res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
  res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
  res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

  return res

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

print(rec(0,0,0,0)) import sys sys def input():
  return sys.stdin.readline().rstrip() input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def rec(i,a,b,c):
  if i==N:
    if a==0 or b==0 or c==0:
      return 10**12
    return abs(a-A)+abs(b-B)+abs(c-C)

  res=rec(i+1,a,b,c);

  res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
  res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
  res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

  return res rec if i==N:
    if a==0 or b==0 or c==0:
      return 10**12
    return abs(a-A)+abs(b-B)+abs(c-C)

   i==N i N if a==0 or b==0 or c==0:
      return 10**12
     a==0 or b==0 or c==0 a==0 or b==0 a==0 a 0 b==0 b 0 c==0 c 0 return 10**12 10**12 10 12 return abs(a-A)+abs(b-B)+abs(c-C) abs(a-A)+abs(b-B)+abs(c-C) abs(a-A)+abs(b-B) abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C res=rec(i+1,a,b,c) res rec(i+1,a,b,c) rec i+1 i 1 a b c res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0)) res min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0)) min res rec(i+1,a+l[i],b,c)+(10 if a else 0) rec(i+1,a+l[i],b,c) rec i+1 i 1 a+l[i] a l[i] l i b c 10 if a else 0 a 10 0 res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0)) res min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0)) min res rec(i+1,a,b+l[i],c)+(10 if b else 0) rec(i+1,a,b+l[i],c) rec i+1 i 1 a b+l[i] b l[i] l i c 10 if b else 0 b 10 0 res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0)) res min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0)) min res rec(i+1,a,b,c+l[i])+(10 if c else 0) rec(i+1,a,b,c+l[i]) rec i+1 i 1 a b c+l[i] c l[i] l i 10 if c else 0 c 10 0 return res res i i a a b b c c 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 _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input l=[int(input()) for _ in range(N)] l [int(input()) for _ in range(N)] print(rec(0,0,0,0)) print rec(0,0,0,0) rec 0 0 0 0 def input():
  return sys.stdin.readline().rstrip() def input():
  return sys.stdin.readline().rstrip() input N,A,B,C=map(int,input().split()) map(int,input().split()) N def rec(i,a,b,c):
  if i==N:
    if a==0 or b==0 or c==0:
      return 10**12
    return abs(a-A)+abs(b-B)+abs(c-C)

  res=rec(i+1,a,b,c);

  res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
  res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
  res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

  return res def rec(i,a,b,c):
  if i==N:
    if a==0 or b==0 or c==0:
      return 10**12
    return abs(a-A)+abs(b-B)+abs(c-C)

  res=rec(i+1,a,b,c);

  res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
  res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
  res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

  return res rec B,C=map(int,input().split()) map(int,input().split()) B C=map(int,input().split()) map(int,input().split()) C A,B,C=map(int,input().split()) map(int,input().split()) A l=[int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l
import sys
def input():
  return sys.stdin.readline().rstrip()

def rec(i,a,b,c):
  if i==N:
    if a==0 or b==0 or c==0:
      return 10**12
    return abs(a-A)+abs(b-B)+abs(c-C)

  res=rec(i+1,a,b,c);

  res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
  res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
  res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

  return res

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

print(rec(0,0,0,0))
