using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace abc119c
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var numBamboos = temp[0];
            List<int> requests = new List<int> { temp[1], temp[2], temp[3] };
            var materials = new List<int>();

            for (int i = 0; i < numBamboos; i++)
            {
                materials.Add(int.Parse(Console.ReadLine()));
            }

            Console.Error.WriteLine(string.Join(',', requests));
            Console.Error.WriteLine(string.Join(',', materials));

            Console.WriteLine(Craft(materials, requests));
        }

        int Craft(List<int> materials, List<int> requests)
        {
            if (materials.Count == 0) return 1000000000;
            if (requests.Count == 0) return 0;
            Console.Error.WriteLine("temp : " + string.Join(',', materials) + " : " + string.Join(',', requests));

            var min = int.MaxValue;
            var request = requests.First();

            foreach (int material in materials)
            {
                // 1本選んで使う
                var m = new List<int>(materials);
                var r = new List<int>(requests);
                m.Remove(material);
                r.Remove(request);
                var mp = Math.Abs(material - request) + Craft(m, r);

                if (mp < min)
                {
                    min = mp;
                }

                // 1本選んで次の竹と合成して使う
                if (requests.Count < materials.Count)
                {
                    m = new List<int>(materials);
                    r = new List<int>(requests);
                    m.Remove(material);
                    r.Remove(request);
                    r.Insert(0, request - material);
                    mp = 10 + Craft(m, r);

                    if (mp < min)
                    {
                        min = mp;
                    }

                    // 選ばない
                    m = new List<int>(materials);
                    r = new List<int>(requests);
                    m.Remove(material);
                    mp = Craft(m, r);

                    if (mp < min)
                    {
                        min = mp;
                    }
                }

                if (min == 0)
                {
                    break;
                }
            }

            return min;
        }
    }
}
