using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class Program
{
    enum ABC {
        N = 0,A = 1,B = 2,C = 3
    }
    static int Getnn(List<ABC> value) { //Get not N
        int Result = 0;
        foreach(ABC v in value) {
            if (v != ABC.N) Result++;
        }
        return Result;
    }
    static void Main(string[] Args) {
        var list = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        var l = new List<int>();
        for (int i = 0; i < list[0]; i++)
            l.Add(Int32.Parse(ReadLine()));

        List<int> MPs = new List<int>();

        void DFS(int depth,List<ABC> value) {
            if(depth == list[0]) {
                int A = 0;
                int B = 0;
                int C = 0;
                int MP_tmp = (Getnn(value) -3) * 10;
                for(int Count = 0;Count < list[0]; Count++) {
                    if (value[Count] == ABC.A) A += l[Count];
                    else if (value[Count] == ABC.B) B += l[Count];
                    else if (value[Count] == ABC.C) C += l[Count];
                }
                MP_tmp += Math.Abs(list[1] - A);
                MP_tmp += Math.Abs(list[2] - B);
                MP_tmp += Math.Abs(list[3] - C);
                MPs.Add(MP_tmp);
                return;
            }

            for (int i = 0;i <= 3; i++) {
                List<ABC> clone = new List<ABC>(value);
                clone.Add((ABC)i);
                //WriteLine(depth);
                DFS(depth + 1, clone);
            }
        }

        List<ABC> vs = new List<ABC>();
        DFS(0, vs);

        WriteLine(MPs.Min());

        ReadLine();
    }
}