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

class Program
{
    private static int MP = 0;
    private static bool exit = false;

    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        var n = input[0];
        var a = input[1];
        var b = input[2];
        var c = input[3];
        var take = new List<int>();
        for (int i = 0; i < n; i++)
        {
            take.Add(int.Parse(Console.ReadLine()));
        }

        take.Sort((x, y) => y - x);

        var needs = new List<int> { a, b, c };
        var targets = new List<int>();

        for (int i = 0; i < 3; i++)
        {
            if (!take.Any(x => x == needs[i]))
            {
                targets.Add(needs[i]);
            }
            else
            {
                take.Remove(needs[i]);
            }
        }

        if (targets.Count == 0)
        {
            Console.WriteLine(0);
            return;
        }

        foreach (var target in targets)
        {
            var flag = false;
            while (true)
            {
                if (flag)
                {
                    break;
                }

                var mindex = 0;
                var min = int.MaxValue;
                for (int i = 0; i < take.Count; i++)
                {
                    var miv = 差を出す(target, take[i]);
                    if (min >= miv)
                    {
                        min = miv;
                        mindex = i;
                    }
                }

                if (min <= 10)
                {
                    MP += min;
                    take.RemoveAt(mindex);
                    flag = true;
                    continue;
                }

                var nextIndex = 0;
                min = int.MaxValue;
                for (int i = mindex + 1; i < take.Count; i++)
                {
                    var minext = 差を出す(target, take[mindex] + take[i]);
                    if (min >= minext)
                    {
                        min = minext;
                        nextIndex = i;
                    }
                }

                MP += 10;
                take[mindex] += take[nextIndex];
                take.RemoveAt(nextIndex);
                take.Sort((x, y) => y - x);
            }
        }

        Console.WriteLine(MP);
    }

    private static int 差を出す(int target, int v)
    {
        return Math.Abs(Math.Max(target, v) - Math.Min(target, v));
    }
}