# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,a,b,c = lr()
l = [ir() for i in range(n)]
l.sort(reverse=True)

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

ans = inf

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            now = [l[i],l[j],l[k]]
            ret = [0 for w in range(5-(n-3))]
            pre = 0
            for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
            for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2]))
print(ans) import math math import fractions fractions import sys sys import bisect bisect import heapq heapq import collections collections from collections import Counter from collections import deque import pprint pprint import itertools itertools sr = lambda: input() sr lambda: input() input() input ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split """nを素因数分解""" """2以上の整数n => [[素因数, 指数], ...]の2次元リスト""" def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n factorization arr = [] arr [] temp = n temp n if n == 1:
        return arr

     n == 1 n 1 return arr arr for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

     i range(2, int(-(-n ** 0.5 // 1)) + 1) range 2 int(-(-n ** 0.5 // 1)) + 1 int(-(-n ** 0.5 // 1)) int -(-n ** 0.5 // 1) -n ** 0.5 // 1 -n ** 0.5 n ** 0.5 n 0.5 1 1 if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

     temp % i == 0 temp % i temp i 0 cnt = 0 cnt 0 while temp % i == 0:
                cnt += 1
                temp //= i
             temp % i == 0 temp % i temp i 0 cnt += 1 cnt 1 temp //= i temp i arr.append([i, cnt]) arr.append arr append [i, cnt] i cnt if temp != 1:
        arr.append([temp, 1])

     temp != 1 temp 1 arr.append([temp, 1]) arr.append arr append [temp, 1] temp 1 if arr == []:
        arr.append([n, 1])

     arr == [] arr [] arr.append([n, 1]) arr.append arr append [n, 1] n 1 return arr arr n n def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l power x = 1 x 1 while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
     n if n & 1:
            x *= a % mod
         n & 1 n 1 x *= a % mod x a % mod a mod n >>= 1 n 1 a *= a % mod a a % mod a mod return x % mod x % mod x mod a a n n mod mod def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a kaijo if n == 0:
        return 1
     n == 0 n 0 return 1 1 a = n a n tmp = n - 1 tmp n - 1 n 1 while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
     tmp >= l tmp l a = a * tmp % mod a a * tmp % mod a * tmp a tmp mod tmp -= 1 tmp 1 return a a n n l l mod mod inf = 10 ** 18 inf 10 ** 18 10 18 mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 n,a,b,c = lr() n lr() lr a b c ir() for i in range(n) for i in range(n) i range(n) range n for i in range(n) ir() ir l = [ir() for i in range(n)] l [ir() for i in range(n)] l.sort(reverse=True) l.sort l sort reverse=True reverse True def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b) base10to if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
     int(n/b) int n/b n b return base10to(int(n/b), b) + str(n%b) base10to(int(n/b), b) + str(n%b) base10to(int(n/b), b) base10to int(n/b) int n/b n b b str(n%b) str n%b n b return str(n%b) str(n%b) str n%b n b n n b b ans = inf ans inf for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            now = [l[i],l[j],l[k]]
            ret = [0 for w in range(5-(n-3))]
            pre = 0
            for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
            for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        for k in range(j+1,n):
            now = [l[i],l[j],l[k]]
            ret = [0 for w in range(5-(n-3))]
            pre = 0
            for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
            for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) j range(i+1,n-1) range i+1 i 1 n-1 n 1 for k in range(j+1,n):
            now = [l[i],l[j],l[k]]
            ret = [0 for w in range(5-(n-3))]
            pre = 0
            for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
            for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) k range(j+1,n) range j+1 j 1 n now = [l[i],l[j],l[k]] now [l[i],l[j],l[k]] l[i] l i l[j] l j l[k] l k 0 for w in range(5-(n-3)) for w in range(5-(n-3)) w range(5-(n-3)) range 5-(n-3) 5 n-3 n 3 for w in range(5-(n-3)) 0 ret = [0 for w in range(5-(n-3))] ret [0 for w in range(5-(n-3))] pre = 0 pre 0 for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
             g range(n) range n if g!=i and g!=j and g!=k:
                    ret.append(l[g])
             g!=i and g!=j and g!=k g!=i and g!=j g!=i g i g!=j g j g!=k g k ret.append(l[g]) ret.append ret append l[g] l g for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) h range(4**(n-3)) range 4**(n-3) 4 n-3 n 3 now = [l[i], l[j], l[k]] now [l[i], l[j], l[k]] l[i] l i l[j] l j l[k] l k pre = 0 pre 0 judge = base10to(h, 4) judge base10to(h, 4) base10to h 4 tmp = '' tmp '' for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                 w range(5-len(judge)) range 5-len(judge) 5 len(judge) len judge tmp = ''.join([tmp,'0']) tmp ''.join([tmp,'0']) ''.join '' join [tmp,'0'] tmp '0' judge = ''.join([tmp,judge]) judge ''.join([tmp,judge]) ''.join '' join [tmp,judge] tmp judge for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                 p t enumerate(judge) enumerate judge if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                 t == '1' t '1' now[0]+=ret[p] now[0] now 0 ret[p] ret p pre+=10 pre 10 elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                     t == '2' t '2' now[1]+=ret[p] now[1] now 1 ret[p] ret p pre+=10 pre 10 elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                 t == '3' t '3' now[2]+=ret[p] now[2] now 2 ret[p] ret p pre+=10 pre 10 now.sort(reverse=True) now.sort now sort reverse=True reverse True ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) ans min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) min ans pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2]) pre+abs(a-now[0])+abs(b-now[1]) pre+abs(a-now[0]) pre abs(a-now[0]) abs a-now[0] a now[0] now 0 abs(b-now[1]) abs b-now[1] b now[1] now 1 abs(c-now[2]) abs c-now[2] c now[2] now 2 print(ans) print ans n,a,b,c = lr() lr() n now = [l[i],l[j],l[k]] [l[i],l[j],l[k]] now l = [ir() for i in range(n)] [ir() for i in range(n)] l def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n factorization b,c = lr() lr() b pre+=10 10 pre judge = base10to(h, 4) base10to(h, 4) judge judge = ''.join([tmp,judge]) ''.join([tmp,judge]) judge sr = lambda: input() lambda: input() sr c = lr() lr() c ret = [0 for w in range(5-(n-3))] [0 for w in range(5-(n-3))] ret pre = 0 0 pre def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a kaijo pre+=10 10 pre ir = lambda: int(sr()) lambda: int(sr()) ir def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b) def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b) base10to pre = 0 0 pre tmp = '' '' tmp def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l power mod = 10 ** 9 + 7 10 ** 9 + 7 mod inf = 10 ** 18 10 ** 18 inf a,b,c = lr() lr() a ans = inf inf ans lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr now = [l[i], l[j], l[k]] [l[i], l[j], l[k]] now pre+=10 10 pre tmp = ''.join([tmp,'0']) ''.join([tmp,'0']) tmp ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2])) ans
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,a,b,c = lr()
l = [ir() for i in range(n)]
l.sort(reverse=True)

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

ans = inf

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            now = [l[i],l[j],l[k]]
            ret = [0 for w in range(5-(n-3))]
            pre = 0
            for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
            for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2]))
print(ans)