# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
 
from itertools import product
ans = float("inf")

# 全パターン試す
# 0 : 使わない
# 1,2,3 : A,B,Cとして使う
for p in product(range(4),repeat=N):
    a = [L[i] for i in range(N) if p[i]==1]
    b = [L[i] for i in range(N) if p[i]==2]
    c = [L[i] for i in range(N) if p[i]==3]
 
    if a==[] or b==[] or c==[]:
        continue
    
    t = 0
    for x in [a,b,c]:
        # 複数要素あるなら合成魔法を使って1つに
        if len(x)>=2:
            t += (len(x)-1)*10
    sumA = sum(a)
    sumB = sum(b)
    sumC = sum(c)
    # 目標との差分を 延長魔法or短縮魔法 で埋める
    t += abs(A-sumA) + abs(B-sumB) + abs(C-sumC)
 
    ans = min(ans,t)
 
print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input L = [int(input()) for _ in range(N)] L [int(input()) for _ in range(N)] from itertools import product ans = float("inf") ans float("inf") float "inf" for p in product(range(4),repeat=N):
    a = [L[i] for i in range(N) if p[i]==1]
    b = [L[i] for i in range(N) if p[i]==2]
    c = [L[i] for i in range(N) if p[i]==3]
 
    if a==[] or b==[] or c==[]:
        continue
    
    t = 0
    for x in [a,b,c]:
        # 複数要素あるなら合成魔法を使って1つに
        if len(x)>=2:
            t += (len(x)-1)*10
    sumA = sum(a)
    sumB = sum(b)
    sumC = sum(c)
    # 目標との差分を 延長魔法or短縮魔法 で埋める
    t += abs(A-sumA) + abs(B-sumB) + abs(C-sumC)
 
    ans = min(ans,t)
  p product(range(4),repeat=N) product range(4) range 4 repeat=N repeat N L[i] for i in range(N) if p[i]==1 for i in range(N) if p[i]==1 i range(N) range N p[i]==1 p[i] p i 1 if p[i]==1 L[i] L i a = [L[i] for i in range(N) if p[i]==1] a [L[i] for i in range(N) if p[i]==1] L[i] for i in range(N) if p[i]==2 for i in range(N) if p[i]==2 i range(N) range N p[i]==2 p[i] p i 2 if p[i]==2 L[i] L i b = [L[i] for i in range(N) if p[i]==2] b [L[i] for i in range(N) if p[i]==2] L[i] for i in range(N) if p[i]==3 for i in range(N) if p[i]==3 i range(N) range N p[i]==3 p[i] p i 3 if p[i]==3 L[i] L i c = [L[i] for i in range(N) if p[i]==3] c [L[i] for i in range(N) if p[i]==3] if a==[] or b==[] or c==[]:
        continue
    
     a==[] or b==[] or c==[] a==[] or b==[] a==[] a [] b==[] b [] c==[] c [] continue t = 0 t 0 for x in [a,b,c]:
        # 複数要素あるなら合成魔法を使って1つに
        if len(x)>=2:
            t += (len(x)-1)*10
     x [a,b,c] a b c if len(x)>=2:
            t += (len(x)-1)*10
     len(x)>=2 len(x) len x 2 t += (len(x)-1)*10 t (len(x)-1)*10 len(x)-1 len(x) len x 1 10 sumA = sum(a) sumA sum(a) sum a sumB = sum(b) sumB sum(b) sum b sumC = sum(c) sumC sum(c) sum c t += abs(A-sumA) + abs(B-sumB) + abs(C-sumC) t abs(A-sumA) + abs(B-sumB) + abs(C-sumC) abs(A-sumA) + abs(B-sumB) abs(A-sumA) abs A-sumA A sumA abs(B-sumB) abs B-sumB B sumB abs(C-sumC) abs C-sumC C sumC ans = min(ans,t) ans min(ans,t) min ans t print(ans) print ans B,C = map(int,input().split()) map(int,input().split()) B t += abs(A-sumA) + abs(B-sumB) + abs(C-sumC) abs(A-sumA) + abs(B-sumB) + abs(C-sumC) t input = sys.stdin.readline sys.stdin.readline input t += (len(x)-1)*10 (len(x)-1)*10 t ans = min(ans,t) min(ans,t) ans b = [L[i] for i in range(N) if p[i]==2] [L[i] for i in range(N) if p[i]==2] b a = [L[i] for i in range(N) if p[i]==1] [L[i] for i in range(N) if p[i]==1] a L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L A,B,C = map(int,input().split()) map(int,input().split()) A c = [L[i] for i in range(N) if p[i]==3] [L[i] for i in range(N) if p[i]==3] c sumB = sum(b) sum(b) sumB C = map(int,input().split()) map(int,input().split()) C t = 0 0 t sumC = sum(c) sum(c) sumC sumA = sum(a) sum(a) sumA N,A,B,C = map(int,input().split()) map(int,input().split()) N ans = float("inf") float("inf") ans
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
 
from itertools import product
ans = float("inf")

# 全パターン試す
# 0 : 使わない
# 1,2,3 : A,B,Cとして使う
for p in product(range(4),repeat=N):
    a = [L[i] for i in range(N) if p[i]==1]
    b = [L[i] for i in range(N) if p[i]==2]
    c = [L[i] for i in range(N) if p[i]==3]
 
    if a==[] or b==[] or c==[]:
        continue
    
    t = 0
    for x in [a,b,c]:
        # 複数要素あるなら合成魔法を使って1つに
        if len(x)>=2:
            t += (len(x)-1)*10
    sumA = sum(a)
    sumB = sum(b)
    sumC = sum(c)
    # 目標との差分を 延長魔法or短縮魔法 で埋める
    t += abs(A-sumA) + abs(B-sumB) + abs(C-sumC)
 
    ans = min(ans,t)
 
print(ans)