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

namespace ABC119C
{
    public partial class Program
    {
        int N;
        int A;
        int B;
        int C;
        List<int> L;

        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            N = ss.Next(int.Parse);
            A = ss.Next(int.Parse);
            B = ss.Next(int.Parse);
            C = ss.Next(int.Parse);
            L = ss.Next(int.Parse, N).ToList();

            var ans = DFS(0, 0);
            sw.WriteLine(ans);
            //---------------------------------
        }

        int DFS(int index, int mp)
        {
            if (L.Contains(A) && L.Contains(B) && L.Contains(C)) return mp;
            if (index >= L.Count) return int.MaxValue;

            var ret = new List<int>();
            var cl = L[index];

            ret.Add(DFS(index + 1, mp));

            L[index] = A;
            ret.Add(DFS(index + 1, mp + Math.Abs(A - cl)));
            L[index] = B;
            ret.Add(DFS(index + 1, mp + Math.Abs(B - cl)));
            L[index] = C;
            ret.Add(DFS(index + 1, mp + Math.Abs(C - cl)));

            for (var i = index + 1; i < L.Count; i++)
            {
                var r = L[i];
                L.RemoveAt(i);
                L[index] = cl + r;
                if (cl + r <= 2000) ret.Add(DFS(index, mp + 10));
                L.Insert(i, r);
            }

            L[index] = cl;
            return ret.Min();
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = { ' ' };
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

Measured memory_bytes: 17336