import sys
import numpy as np

def update(df, ol, t):
  ol = ol[ol!=10000].reshape(-1, 3)
  df = df[df!=10000].reshape(-1, 3)
  print(ol)
  print(df)
  for idx in range(ol.shape[1]):
    min_a = np.argmin(ol[:,idx])
    max_a = np.argmax(ol[:,idx])
    ol[max_a] = ol[min_a] + ol[max_a]
    ol[min_a] = 0
  ol = ol[ol!=0].reshape(-1,3)
  df = t - ol
  return df, ol

v = []
for line in sys.stdin:
    v.append([int(i) for i in line.split()])

a, b, c = v[0][1:]
t = [a, b, c]
l = np.squeeze(np.array(v[1:]))
ol = np.zeros((3, len(l)))
ol[0] = l
ol[1] = l
ol[2] = l
ol = ol.transpose()
df = np.zeros((3, len(l)))
df[0] = np.array([a] * len(l)) - l
df[1] = np.array([b] * len(l)) - l
df[2] = np.array([c] * len(l)) - l
df = df.transpose()
count = 0
mp = 0
while count != 3:
  for idx, df_v in enumerate(df):
    min_v = np.min(np.abs(df_v))
    min_v_arg = np.argmin(np.abs(df_v))
    
    if min_v <= 10:
      ol[idx,:] = 10000
      df[idx,:] = 10000
      t[min_v_arg] = -1
      count += 1
      mp += min_v
      if count == 3:
        break
  if count == 3:
    break
  df, ol = update(df, ol, t)
  mp += 10
print(np.int(mp))