// ABC 119

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

class Program
{
    static int N;
    static int A;
    static int B;
    static int C;
    static int[] l;

    static void Main()
    {
        int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = inp[0];
        A = inp[1];
        B = inp[2];
        C = inp[3];
        l = new int[N];
        for (int i = 0; i < N; i++)
            l[i] = int.Parse(Console.ReadLine());

        List<int> bam = new List<int>();
        foreach (var i in l) bam.Add(i);
        Console.WriteLine(Solv(bam));
    }

    /* 合成魔法なし */
    static int Min(List<int> bam)
    {
        int[] a = bam.Select(s => Math.Abs(s - A)).ToArray();
        int[] b = bam.Select(s => Math.Abs(s - B)).ToArray();
        int[] c = bam.Select(s => Math.Abs(s - C)).ToArray();
        int min = 0;
        min += a.Min();
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] == a.Min())
            {
                b[i] = int.MaxValue;
                c[i] = int.MaxValue;
                break;
            }
        }
        min += b.Min();
        for (int i = 0; i < a.Length; i++)
        {
            if (b[i] == b.Min())
            {
                c[i] = int.MaxValue;
                break;
            }
        }
        min += c.Min();
        return min;
    }

    static int Solv(List<int> bam)
    {
        if (bam.Count < 3) return int.MaxValue;
        if (bam.Count == 3) return Min(bam);
        int rv = Min(bam);
        if (rv == 0) return 0;
        for (int i = 0; i < bam.Count; i++)
        {
            for (int j = i + 1; j < bam.Count; j++)
            {
                if (i == j) continue;
                if (bam[i] <= 10 || bam[j] <= 10) continue;
                List<int> bam2 = new List<int>();
                for (int k = 0; k < bam.Count; k++)
                    if (k != i && k != j)
                        bam2.Add(bam[k]);
                bam2.Add(bam[i] + bam[j]);
                rv = Math.Min(rv, Solv(bam2) + 10);
            }
        }
        return rv;
    }
}