N, A, B, C = [int(item) for item in input().split()]

take = [int(input()) for i in range(N)]

def dfs(n, a, b, c):
  if n == N:
    return abs(a - A) + abs(b - B) + abs(c - C) if min(a, b, c) > 0 else 10**9
  ret0 = dfs(n+1, a+take[n], b, c)
  ret1 = dfs(n+1, a, b+take[n], c)
  ret2 = dfs(n+1, a, b, c+take[n])
  ret3 = dfs(n+1, a, b, c)
  return min(ret0, ret1, ret2, ret3)

ans = dfs(0, 0, 0, 0)
print(ans)