def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, A, B, C = getNM()
L = getArray(N)

def counter(array):
    if (1 in array) and (2 in array) and (3 in array):
        opt = [0, 0, 0, 0]
        # 合成に10pかかる
        cnt = 0
        for i in range(len(array)):
            if opt[array[i]] > 0:
                cnt += 1
            if array[i] >= 1:
                opt[array[i]] += L[i]

        res = cnt * 10
        res += abs(opt[1] - A)
        res += abs(opt[2] - B)
        res += abs(opt[3] - C)

        return res

    else:
        return float('inf')

ans = float('inf')
def four_pow(i, array):
    global ans
    if i == N:
        ans = min(ans, counter(array))
        return
    # 4 ** Nループ
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array)

four_pow(0, [])
print(ans)

"""
4 ** Nループ
N = 5
L = [1, 1, 1, 1, 1]
cnt = 0
def four_pow(i, array):
    global cnt
    if i == N:
        cnt += 1
        return
    # ここの4を変えてrootを変更
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array)

four_pow(0, [])
# 1024
print(cnt)
""" def getN():
    return int(input()) getN return int(input()) int(input()) int input() input def getNM():
    return map(int, input().split()) getNM return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def getList():
    return list(map(int, input().split())) getList return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def getArray(intn):
    return [int(input()) for i in range(intn)] getArray int(input()) for i in range(intn) for i in range(intn) i range(intn) range intn for i in range(intn) int(input()) int input() input return [int(input()) for i in range(intn)] [int(input()) for i in range(intn)] intn intn 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 rand_N(ran1, ran2):
    return random.randint(ran1, ran2) rand_N return random.randint(ran1, ran2) random.randint(ran1, ran2) random.randint random randint ran1 ran2 ran1 ran1 ran2 ran2 def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)] rand_List random.randint(ran1, ran2) for i in range(rantime) for i in range(rantime) i range(rantime) range rantime for i in range(rantime) random.randint(ran1, ran2) random.randint random randint ran1 ran2 return [random.randint(ran1, ran2) for i in range(rantime)] [random.randint(ran1, ran2) for i in range(rantime)] ran1 ran1 ran2 ran2 rantime rantime def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns) rand_ints_nodup ns = [] ns [] while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
   len(ns) < rantime len(ns) len ns rantime n = random.randint(ran1, ran2) n random.randint(ran1, ran2) random.randint random randint ran1 ran2 if not n in ns:
      ns.append(n)
   not n in ns n in ns n ns ns.append(n) ns.append ns append n return sorted(ns) sorted(ns) sorted ns ran1 ran1 ran2 ran2 rantime rantime def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query) rand_query r_query = [] r_query [] while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
   len(r_query) < rantime len(r_query) len r_query rantime n_q = rand_ints_nodup(ran1, ran2, 2) n_q rand_ints_nodup(ran1, ran2, 2) rand_ints_nodup ran1 ran2 2 if not n_q in r_query:
      r_query.append(n_q)
   not n_q in r_query n_q in r_query n_q r_query r_query.append(n_q) r_query.append r_query append n_q return sorted(r_query) sorted(r_query) sorted r_query ran1 ran1 ran2 ran2 rantime rantime from collections import defaultdict, deque, Counter from sys import exit from decimal import * import heapq heapq import math math from fractions import gcd import random random import string string import copy copy from itertools import combinations, permutations, product from operator import mul from functools import reduce from bisect import bisect_left, bisect_right import sys sys sys.setrecursionlimit(1000000000) sys.setrecursionlimit sys setrecursionlimit 1000000000 mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 N, A, B, C = getNM() N getNM() getNM A B C L = getArray(N) L getArray(N) getArray N def counter(array):
    if (1 in array) and (2 in array) and (3 in array):
        opt = [0, 0, 0, 0]
        # 合成に10pかかる
        cnt = 0
        for i in range(len(array)):
            if opt[array[i]] > 0:
                cnt += 1
            if array[i] >= 1:
                opt[array[i]] += L[i]

        res = cnt * 10
        res += abs(opt[1] - A)
        res += abs(opt[2] - B)
        res += abs(opt[3] - C)

        return res

    else:
        return float('inf') counter if (1 in array) and (2 in array) and (3 in array):
        opt = [0, 0, 0, 0]
        # 合成に10pかかる
        cnt = 0
        for i in range(len(array)):
            if opt[array[i]] > 0:
                cnt += 1
            if array[i] >= 1:
                opt[array[i]] += L[i]

        res = cnt * 10
        res += abs(opt[1] - A)
        res += abs(opt[2] - B)
        res += abs(opt[3] - C)

        return res

    else:
        return float('inf') (1 in array) and (2 in array) and (3 in array) (1 in array) and (2 in array) 1 in array 1 array 2 in array 2 array 3 in array 3 array opt = [0, 0, 0, 0] opt [0, 0, 0, 0] 0 0 0 0 cnt = 0 cnt 0 for i in range(len(array)):
            if opt[array[i]] > 0:
                cnt += 1
            if array[i] >= 1:
                opt[array[i]] += L[i]

         i range(len(array)) range len(array) len array if opt[array[i]] > 0:
                cnt += 1
             opt[array[i]] > 0 opt[array[i]] opt array[i] array i 0 cnt += 1 cnt 1 if array[i] >= 1:
                opt[array[i]] += L[i]

         array[i] >= 1 array[i] array i 1 opt[array[i]] += L[i] opt[array[i]] opt array[i] array i L[i] L i res = cnt * 10 res cnt * 10 cnt 10 res += abs(opt[1] - A) res abs(opt[1] - A) abs opt[1] - A opt[1] opt 1 A res += abs(opt[2] - B) res abs(opt[2] - B) abs opt[2] - B opt[2] opt 2 B res += abs(opt[3] - C) res abs(opt[3] - C) abs opt[3] - C opt[3] opt 3 C return res res return float('inf') float('inf') float 'inf' array array ans = float('inf') ans float('inf') float 'inf' def four_pow(i, array):
    global ans
    if i == N:
        ans = min(ans, counter(array))
        return
    # 4 ** Nループ
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array) four_pow global ans if i == N:
        ans = min(ans, counter(array))
        return
    # 4 ** Nループ
     i == N i N ans = min(ans, counter(array)) ans min(ans, counter(array)) min ans counter(array) counter array return for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array) j range(4) range 4 new_array = array + [j] new_array array + [j] array [j] j four_pow(i + 1, new_array) four_pow i + 1 i 1 new_array i i array array four_pow(0, []) four_pow 0 [] print(ans) print ans """
4 ** Nループ
N = 5
L = [1, 1, 1, 1, 1]
cnt = 0
def four_pow(i, array):
    global cnt
    if i == N:
        cnt += 1
        return
    # ここの4を変えてrootを変更
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array)

four_pow(0, [])
# 1024
print(cnt)
""" def rand_N(ran1, ran2):
    return random.randint(ran1, ran2) def rand_N(ran1, ran2):
    return random.randint(ran1, ran2) rand_N C = getNM() getNM() C mod = 10 ** 9 + 7 10 ** 9 + 7 mod def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)] def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)] rand_List def four_pow(i, array):
    global ans
    if i == N:
        ans = min(ans, counter(array))
        return
    # 4 ** Nループ
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array) def four_pow(i, array):
    global ans
    if i == N:
        ans = min(ans, counter(array))
        return
    # 4 ** Nループ
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array) four_pow def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query) def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query) rand_query def counter(array):
    if (1 in array) and (2 in array) and (3 in array):
        opt = [0, 0, 0, 0]
        # 合成に10pかかる
        cnt = 0
        for i in range(len(array)):
            if opt[array[i]] > 0:
                cnt += 1
            if array[i] >= 1:
                opt[array[i]] += L[i]

        res = cnt * 10
        res += abs(opt[1] - A)
        res += abs(opt[2] - B)
        res += abs(opt[3] - C)

        return res

    else:
        return float('inf') def counter(array):
    if (1 in array) and (2 in array) and (3 in array):
        opt = [0, 0, 0, 0]
        # 合成に10pかかる
        cnt = 0
        for i in range(len(array)):
            if opt[array[i]] > 0:
                cnt += 1
            if array[i] >= 1:
                opt[array[i]] += L[i]

        res = cnt * 10
        res += abs(opt[1] - A)
        res += abs(opt[2] - B)
        res += abs(opt[3] - C)

        return res

    else:
        return float('inf') counter ans = float('inf') float('inf') ans def getN():
    return int(input()) def getN():
    return int(input()) getN def getNM():
    return map(int, input().split()) def getNM():
    return map(int, input().split()) getNM def getArray(intn):
    return [int(input()) for i in range(intn)] def getArray(intn):
    return [int(input()) for i in range(intn)] getArray N, A, B, C = getNM() getNM() N B, C = getNM() getNM() B L = getArray(N) getArray(N) L A, B, C = getNM() getNM() A def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns) def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns) rand_ints_nodup def getList():
    return list(map(int, input().split())) def getList():
    return list(map(int, input().split())) getList
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, A, B, C = getNM()
L = getArray(N)

def counter(array):
    if (1 in array) and (2 in array) and (3 in array):
        opt = [0, 0, 0, 0]
        # 合成に10pかかる
        cnt = 0
        for i in range(len(array)):
            if opt[array[i]] > 0:
                cnt += 1
            if array[i] >= 1:
                opt[array[i]] += L[i]

        res = cnt * 10
        res += abs(opt[1] - A)
        res += abs(opt[2] - B)
        res += abs(opt[3] - C)

        return res

    else:
        return float('inf')

ans = float('inf')
def four_pow(i, array):
    global ans
    if i == N:
        ans = min(ans, counter(array))
        return
    # 4 ** Nループ
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array)

four_pow(0, [])
print(ans)

"""
4 ** Nループ
N = 5
L = [1, 1, 1, 1, 1]
cnt = 0
def four_pow(i, array):
    global cnt
    if i == N:
        cnt += 1
        return
    # ここの4を変えてrootを変更
    for j in range(4):
        new_array = array + [j]
        four_pow(i + 1, new_array)

four_pow(0, [])
# 1024
print(cnt)
"""