def main():
  n, a, b, c = map(int, input().split())

  l = [int(input()) for i in range(n)]

  def test(i, x, y, z):
    if(i == n):
      if(x == 0 or y == 0 or z == 0):
        return float('inf')
      return abs(a - x) + abs(b - y) + abs(c - z)

    res = test(i + 1, x, y, z)

    res = min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) 
    res = min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) 
    res = min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) 

    return res

  print(test(0, 0, 0, 0))

if __name__ == '__main__':
  main() def main():
  n, a, b, c = map(int, input().split())

  l = [int(input()) for i in range(n)]

  def test(i, x, y, z):
    if(i == n):
      if(x == 0 or y == 0 or z == 0):
        return float('inf')
      return abs(a - x) + abs(b - y) + abs(c - z)

    res = test(i + 1, x, y, z)

    res = min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) 
    res = min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) 
    res = min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) 

    return res

  print(test(0, 0, 0, 0)) main 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 i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] def test(i, x, y, z):
    if(i == n):
      if(x == 0 or y == 0 or z == 0):
        return float('inf')
      return abs(a - x) + abs(b - y) + abs(c - z)

    res = test(i + 1, x, y, z)

    res = min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) 
    res = min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) 
    res = min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) 

    return res

   test if(i == n):
      if(x == 0 or y == 0 or z == 0):
        return float('inf')
      return abs(a - x) + abs(b - y) + abs(c - z)

     i == n i n if(x == 0 or y == 0 or z == 0):
        return float('inf')
       x == 0 or y == 0 or z == 0 x == 0 or y == 0 x == 0 x 0 y == 0 y 0 z == 0 z 0 return float('inf') float('inf') float 'inf' return abs(a - x) + abs(b - y) + abs(c - z) abs(a - x) + abs(b - y) + abs(c - z) abs(a - x) + abs(b - y) abs(a - x) abs a - x a x abs(b - y) abs b - y b y abs(c - z) abs c - z c z res = test(i + 1, x, y, z) res test(i + 1, x, y, z) test i + 1 i 1 x y z res = min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) res min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) min res test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10) test(i + 1, x + l[i], y, z) test i + 1 i 1 x + l[i] x l[i] l i y z 0 if x == 0 else 10 x == 0 x 0 0 10 res = min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) res min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) min res test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10) test(i + 1, x, y + l[i], z) test i + 1 i 1 x y + l[i] y l[i] l i z 0 if y == 0 else 10 y == 0 y 0 0 10 res = min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) res min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) min res test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10) test(i + 1, x, y, z + l[i]) test i + 1 i 1 x y z + l[i] z l[i] l i 0 if z == 0 else 10 z == 0 z 0 0 10 return res res i i x x y y z z print(test(0, 0, 0, 0)) print test(0, 0, 0, 0) test 0 0 0 0 if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def main():
  n, a, b, c = map(int, input().split())

  l = [int(input()) for i in range(n)]

  def test(i, x, y, z):
    if(i == n):
      if(x == 0 or y == 0 or z == 0):
        return float('inf')
      return abs(a - x) + abs(b - y) + abs(c - z)

    res = test(i + 1, x, y, z)

    res = min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) 
    res = min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) 
    res = min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) 

    return res

  print(test(0, 0, 0, 0)) def main():
  n, a, b, c = map(int, input().split())

  l = [int(input()) for i in range(n)]

  def test(i, x, y, z):
    if(i == n):
      if(x == 0 or y == 0 or z == 0):
        return float('inf')
      return abs(a - x) + abs(b - y) + abs(c - z)

    res = test(i + 1, x, y, z)

    res = min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) 
    res = min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) 
    res = min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) 

    return res

  print(test(0, 0, 0, 0)) main
def main():
  n, a, b, c = map(int, input().split())

  l = [int(input()) for i in range(n)]

  def test(i, x, y, z):
    if(i == n):
      if(x == 0 or y == 0 or z == 0):
        return float('inf')
      return abs(a - x) + abs(b - y) + abs(c - z)

    res = test(i + 1, x, y, z)

    res = min(res, (test(i + 1, x + l[i], y, z) + (0 if x == 0 else 10))) 
    res = min(res, (test(i + 1, x, y + l[i], z) + (0 if y == 0 else 10))) 
    res = min(res, (test(i + 1, x, y, z + l[i]) + (0 if z == 0 else 10))) 

    return res

  print(test(0, 0, 0, 0))

if __name__ == '__main__':
  main()
