from itertools import product
n,*B=map(int,input().split())
A=[int(input()) for i in range(n)]
s=10**9
for P in product([0,1,2,3],repeat=n):
  if {0,1,2}<=set(P):
    m=[0,0,0]
    for x,y in zip(P,A):
      if x!=3:
        m[x]+=y
    t=sum(abs(m-y) for m,y in zip(m,B))
    l=sum(1 for j in P if j!=3)-3
    s=min(s,t+l*10)
print(s) from itertools import product n,*B=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split *B B int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input A=[int(input()) for i in range(n)] A [int(input()) for i in range(n)] s=10**9 s 10**9 10 9 for P in product([0,1,2,3],repeat=n):
  if {0,1,2}<=set(P):
    m=[0,0,0]
    for x,y in zip(P,A):
      if x!=3:
        m[x]+=y
    t=sum(abs(m-y) for m,y in zip(m,B))
    l=sum(1 for j in P if j!=3)-3
    s=min(s,t+l*10) P product([0,1,2,3],repeat=n) product [0,1,2,3] 0 1 2 3 repeat=n repeat n if {0,1,2}<=set(P):
    m=[0,0,0]
    for x,y in zip(P,A):
      if x!=3:
        m[x]+=y
    t=sum(abs(m-y) for m,y in zip(m,B))
    l=sum(1 for j in P if j!=3)-3
    s=min(s,t+l*10) {0,1,2}<=set(P) {0,1,2} set(P) set P m=[0,0,0] m [0,0,0] 0 0 0 for x,y in zip(P,A):
      if x!=3:
        m[x]+=y
     x y zip(P,A) zip P A if x!=3:
        m[x]+=y
     x!=3 x 3 m[x]+=y m[x] m x y t=sum(abs(m-y) for m,y in zip(m,B)) t sum(abs(m-y) for m,y in zip(m,B)) sum abs(m-y) abs m-y m y l=sum(1 for j in P if j!=3)-3 l sum(1 for j in P if j!=3)-3 sum(1 for j in P if j!=3) sum 1 3 s=min(s,t+l*10) s min(s,t+l*10) min s t+l*10 t l*10 l 10 print(s) print s n,*B=map(int,input().split()) map(int,input().split()) n A=[int(input()) for i in range(n)] [int(input()) for i in range(n)] A s=min(s,t+l*10) min(s,t+l*10) s l=sum(1 for j in P if j!=3)-3 sum(1 for j in P if j!=3)-3 l m=[0,0,0] [0,0,0] m s=10**9 10**9 s t=sum(abs(m-y) for m,y in zip(m,B)) sum(abs(m-y) for m,y in zip(m,B)) t
from itertools import product
n,*B=map(int,input().split())
A=[int(input()) for i in range(n)]
s=10**9
for P in product([0,1,2,3],repeat=n):
  if {0,1,2}<=set(P):
    m=[0,0,0]
    for x,y in zip(P,A):
      if x!=3:
        m[x]+=y
    t=sum(abs(m-y) for m,y in zip(m,B))
    l=sum(1 for j in P if j!=3)-3
    s=min(s,t+l*10)
print(s)