using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc119c
{
    class Program
    {
        static void Main(string[] args)
        {
            var nabc = ReadIntList();
            var N = nabc[0];
            var ABC = nabc.Skip(1).ToList();
            var L = new int[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = ReadInt();
            }
            Console.WriteLine(dfs(0, new List<int>()));
#if DEBUG
            Console.ReadKey();
#endif

            int dfs(uint depth, IList<int> choice)
            {
                if(depth == N)
                {
                    if (choice.Count(x => x == 0) * choice.Count(x => x == 1) * choice.Count(x => x == 2) == 0)
                        return int.MaxValue;
                    var A = new List<int>();
                    var B = new List<int>();
                    var C = new List<int>();
                    var mp = 0;
                    for (int i = 0; i < N; i++)
                    {
                        if (choice[i] == 0)
                        {
                            A.Add(L[i]);
                        }
                        else if (choice[i] == 1)
                        {
                            B.Add(L[i]);
                        }
                        else if (choice[i] == 2)
                        {
                            C.Add(L[i]);
                        }
                    }
                    mp+=Math.Abs(A.Sum() - ABC[0]) + A.Count() * 10 - 10;
                    mp+=Math.Abs(B.Sum() - ABC[1]) + B.Count() * 10 - 10;
                    mp+=Math.Abs(C.Sum() - ABC[2]) + C.Count() * 10 - 10;
                    //Console.WriteLine(String.Join(" ", choice) + $" MP : {mp}");
                    return mp;
                }
                var ans = new List<int>();
                for (int i = 0; i < 4; i++)
                {
                    var newChoice = new List<int>(choice);
                    newChoice.Add(i);
                    ans.Add(dfs(depth+1, newChoice));
                }
                return ans.Min();
            }
        }
        
        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static double ReadDouble() => double.Parse(Console.ReadLine());
        private static List<double> ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
    }
}
