def dfs(i,a,b,c):
  if i == N:
    if a == 0 or b == 0 or c == 0:
      return float('inf')
    return abs(a - A) + abs(b - B) + abs(c - C)
  
  res = dfs(i+1,a,b,c)
  res = min(res, dfs(i+1, a + l[i], b, c) ) 
  res = min(res, dfs(i+1, a, b + l[i], c) )
  res = min(res, dfs(i+1, a, b, c + l[i]) ) 
    
  return res

N, A, B, C = list(map(int,input().split()))
l = [0] * N
for i in range(N):
  l[i] = int(input())
  
print(dfs(0,0,0,0))