'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,a,b,c = map(int,ipt().split())
    l = [int(ipt()) for i in range(n)]
    mi = 10**18

    for i in range(4**n):
        sa = 0
        sb = 0
        sc = 0
        na = 0
        nb = 0
        nc = 0
        for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
        if na*nb*nc == 0:
            continue
        nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10
        if nm < mi:
            mi = nm

    print(mi)



    return None

if __name__ == '__main__':
    main() '''
自宅用PCでの解答
''' import math math import itertools itertools import queue queue import bisect bisect from collections import deque,defaultdict import heapq as hpq heapq from sys import stdin,setrecursionlimit ipt = stdin.readline ipt stdin.readline stdin readline setrecursionlimit(10**7) setrecursionlimit 10**7 10 7 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 dir = [(-1,0),(0,-1),(1,0),(0,1)] dir [(-1,0),(0,-1),(1,0),(0,1)] (-1,0) -1 0 (0,-1) 0 -1 (1,0) 1 0 (0,1) 0 1 alp = "abcdefghijklmnopqrstuvwxyz" alp "abcdefghijklmnopqrstuvwxyz" def main():
    n,a,b,c = map(int,ipt().split())
    l = [int(ipt()) for i in range(n)]
    mi = 10**18

    for i in range(4**n):
        sa = 0
        sb = 0
        sc = 0
        na = 0
        nb = 0
        nc = 0
        for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
        if na*nb*nc == 0:
            continue
        nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10
        if nm < mi:
            mi = nm

    print(mi)



    return None main n,a,b,c = map(int,ipt().split()) n map(int,ipt().split()) map int ipt().split() ().split () ipt split a b c int(ipt()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(ipt()) int ipt() ipt l = [int(ipt()) for i in range(n)] l [int(ipt()) for i in range(n)] mi = 10**18 mi 10**18 10 18 for i in range(4**n):
        sa = 0
        sb = 0
        sc = 0
        na = 0
        nb = 0
        nc = 0
        for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
        if na*nb*nc == 0:
            continue
        nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10
        if nm < mi:
            mi = nm

     i range(4**n) range 4**n 4 n sa = 0 sa 0 sb = 0 sb 0 sc = 0 sc 0 na = 0 na 0 nb = 0 nb 0 nc = 0 nc 0 for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
         j range(n) range n ni = i>>(2*j) ni i>>(2*j) i 2*j 2 j if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
         ni&2 ni 2 if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
             ni&1 ni 1 sa += l[j] sa l[j] l j na += 1 na 1 sb += l[j] sb l[j] l j nb += 1 nb 1 elif ni&1:
                sc += l[j]
                nc += 1
         ni&1 ni 1 sc += l[j] sc l[j] l j nc += 1 nc 1 if na*nb*nc == 0:
            continue
         na*nb*nc == 0 na*nb*nc na*nb na nb nc 0 continue nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10 nm abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10 abs(sa-a)+abs(sb-b)+abs(sc-c) abs(sa-a)+abs(sb-b) abs(sa-a) abs sa-a sa a abs(sb-b) abs sb-b sb b abs(sc-c) abs sc-c sc c (na+nb+nc-3)*10 na+nb+nc-3 na+nb+nc na+nb na nb nc 3 10 if nm < mi:
            mi = nm

     nm < mi nm mi mi = nm mi nm print(mi) print mi return None None if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main ipt = stdin.readline stdin.readline ipt mod = 10**9+7 10**9+7 mod dir = [(-1,0),(0,-1),(1,0),(0,1)] [(-1,0),(0,-1),(1,0),(0,1)] dir def main():
    n,a,b,c = map(int,ipt().split())
    l = [int(ipt()) for i in range(n)]
    mi = 10**18

    for i in range(4**n):
        sa = 0
        sb = 0
        sc = 0
        na = 0
        nb = 0
        nc = 0
        for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
        if na*nb*nc == 0:
            continue
        nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10
        if nm < mi:
            mi = nm

    print(mi)



    return None def main():
    n,a,b,c = map(int,ipt().split())
    l = [int(ipt()) for i in range(n)]
    mi = 10**18

    for i in range(4**n):
        sa = 0
        sb = 0
        sc = 0
        na = 0
        nb = 0
        nc = 0
        for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
        if na*nb*nc == 0:
            continue
        nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10
        if nm < mi:
            mi = nm

    print(mi)



    return None main alp = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" alp
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,a,b,c = map(int,ipt().split())
    l = [int(ipt()) for i in range(n)]
    mi = 10**18

    for i in range(4**n):
        sa = 0
        sb = 0
        sc = 0
        na = 0
        nb = 0
        nc = 0
        for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
        if na*nb*nc == 0:
            continue
        nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10
        if nm < mi:
            mi = nm

    print(mi)



    return None

if __name__ == '__main__':
    main()
