#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

class NyaGadgetPositionalNotation
{
public:
	NyaGadgetPositionalNotation(int cardinal)
	{
		cardinal_ = cardinal;
		symbol_index_collection_.push_back(0);
	}
	/**
	@param N進数取得関数
	@note
	 digits桁のN進数として文字列で取得
	**/
	std::string GetN(int digits = 0)
	{	// 位取り記数法で文字列を取得
		std::string positional_nation;

		for (const auto& e : symbol_index_collection_)
			positional_nation += symbols_[e];

		if (digits == 0 || digits == positional_nation.size())
			return positional_nation;

		if (digits < positional_nation.size())
		{
			positional_nation = positional_nation.substr(0, digits);
		}
		else
		{
			std::string zero(digits - positional_nation.size(), '0');
			positional_nation = zero + positional_nation;
		}

		return positional_nation;
	}
	void Inc()
	{	// 返り値なしのインクリメント
		bool carry = true;
		int index = (int)symbol_index_collection_.size() - 1;
		while (0 <= index && carry)
		{
			if (symbol_index_collection_[index] != cardinal_ - 1)
			{
				symbol_index_collection_[index]++;
				carry = false;
			}
			else
			{	// 桁上り
				symbol_index_collection_[index] = 0;
				if (index == 0)
				{
					symbol_index_collection_.push_front(0);
					index++;
				}
				carry = true;
			}
			index--;
		}
	}
	NyaGadgetPositionalNotation operator ++()
	{	// 前置インクリメント
		Inc();
		return *this;
	}
	NyaGadgetPositionalNotation operator ++(int)
	{  // 後置インクリメント
		NyaGadgetPositionalNotation pn = *this;
		Inc();
		return pn;
	}
private:
	int cardinal_;	// 基数
	std::string symbols_[36] =
	{	// 36進数まで対応
		"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
		"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
		"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
		"U", "V", "W", "X", "Y", "Z",
	};
	// シンボルそのものでなく、シンボルに対応するindexを格納していく
	std::deque<int> symbol_index_collection_;
};

class NyaGadgetVector
{
public:
	/**
	@brief 加算関数
	@note
	 collectionの全要素にadd_valueだけ値を加算する
	**/
	template<typename T> static void Add(vector<T>& collection, T add_value)
	{
		for (auto& e : collection)
			e += add_value;
	}
	/**
	@brief 比較関数
	@note
	 collection1とcollection2の中身が同じかどうか調べる。
	 collectionの要素が全て同じなら0を返す。
	 collectionの要素が同じでなければ、異なる要素の個数を返す。
	**/
	template<typename T> static int Compare(const vector<T>& collection1, const vector<T>& collection2)
	{
		int diff = 0;
		int n = min((int)collection1.size(), (int)collection2.size());
		for (int i = 0; i < n; i++)
		{
			if (collection1[i] != collection2[i])
				diff++;
		}
		diff += abs(collection1.size() - collection2.size());

		return diff;
	}
	/**
	@brief 同一要素数取得関数
	@note
	 同じ値の要素が何個ずつあるのか調べる。
	 コンテナinput_collectionの同じ要素の個数を数えてoutput_collectionに結果を格納する。
	 output_collectionの第一引数には要素の値、第二引数には要素の個数が格納される。
	------------------------------------------------------------------------------------------
	[sample code]
	int main() {
		vector<long> input_collection = {10000000000, 10000000000, 2, 1, 2, 2, 2};
		vector<pair<long, int>> count_collection;			// p.first=value, p.second=size
		NyaGadgetVector::CountValue<long>(input_collection, count_collection);

		for (const auto& e : count_collection)
			cout << "(" << e.first << "," << e.second << ")";
		return 0;
	}
	------------------------------------------------------------------------------------------
	[output]
	(1,1)(2,4)(10000000000,2)
	**/
	template<typename T> static void CountValue(const vector<T>& input_collection, vector<pair<T, int>>& output_collection)
	{
		map<T, int> count_collection;
		for (const auto& e : input_collection)
			count_collection[e] += 1;

		for (const auto e : count_collection)
			output_collection.push_back(make_pair(e.first, e.second));
	}
	/**
	@brief 標準入力関数
	@note
	 標準入力から入力されたsize個の値をcollectionに格納する
	**/
	template<typename T> static void InputStream(vector<T>& collection, int size)
	{
		collection.resize(size);
		for (int i = 0; i < size; i++)
			cin >> collection[i];
	}
	/**
	@brief pairの引数を反転させる関数
	@note
	 input_collectionのpair.firstとpair.secondを入れ替えて新たなコンテナを作成する。
	**/
	template<typename T, typename U> static void TurnPair(const vector<pair<T, U>>& input_collection, vector<pair<U, T>>& output_collection)
	{
		for (const auto& e : input_collection)
			output_collection.push_back(make_pair(e.second, e.first));
	}
	/**
	@brief 最大値取得関数
	@note
	 collectionの要素の中で最大値を取得する
	**/
	template<typename T> static T Max(const vector<T>& collection)
	{
		T max = collection[0];
		for (const auto& e : collection)
		{
			if (max < e)
				max = e;
		}
		return max;
	}
	/**
	@brief 最小値取得関数
	@note
	 collectionの要素の中で最小値を取得する
	**/
	template<typename T> static T Min(const vector<T>& collection)
	{
		T min = collection[0];
		for (const auto& e : collection)
		{
			if (e < min)
				min = e;
		}
		return min;
	}
	/**
	@brief 順位取得関数
	@note
	 範囲[min_range, max_range]の値を持つコンテナに対して全要素の順位(値の大きさの順番)を求める。
	 計算量は値の範囲をNとするとO(N)
	-----------------------------------------------------------------------------------------------
	[sample code]
	int main() {
		vector<int> input_collection = {56,0,67,100,67,76};
		vector<int> rank_collection;
		NyaGadgetVector::Rank(0, 100, input_collection, rank_collection);

		cout << "(値, 順位) = ";
		for (const auto &e : input_collection)
			cout << "(" << e  << "," << rank_collection[e] << ")";
		return 0;
	}
	-----------------------------------------------------------------------------------------------
	[output]
	(値, 順位) = (56,5)(0,6)(67,3)(100,1)(67,3)(76,2)
	**/
	static void Rank(int min_range, int max_range, vector<int>& input_collection, vector<int>& rank_collection)
	{
		rank_collection.clear();
		rank_collection.resize(max_range - min_range + 2);
		for (const auto& e : input_collection)
			rank_collection[e]++;

		rank_collection[max_range + 1] = 1;
		for (int i = max_range; min_range <= i; i--)
			rank_collection[i] += rank_collection[i + 1];

		for (int i = 0; i < (int)rank_collection.size() - 1; i++)
			rank_collection[i] = rank_collection[i + 1];
		rank_collection.erase(rank_collection.begin() + ((int)rank_collection.size() - 1));

	}
	/**
	@brief 置換関数
	@note
	 collectionの全要素をreplace_valueに置き換える
	**/
	template<typename T> static void Replace(vector<T>& collection, T replace_value)
	{
		for (auto& e : collection)
			e = replace_value;
	}
	/**
	@brief 合計関数
	@note
	 collectionの要素を合計して返す(範囲はstart_index以上end_index未満)
	**/
	template<typename T> static T Sum(const vector<T>& collection, int start_index, int end_index)
	{
		int sum = 0;
		for (int i = start_index; i < end_index; i++)
			sum += collection[i];
		return sum;
	}
};

class SynthesisSet
{
public:
	int a_;
	int b_;
	int c_;
	string np_permutation_;
	int a_times_;
	int b_times_;
	int c_times_;
};

void Magic10(pair<int, tuple<int, int, int, string, int, int, int>>& synthesis, const vector<int>& l_collection)
{
	loop(i, get<3>(synthesis.second).size())
	{
		if (get<3>(synthesis.second)[i] == '1')
		{
			if (1 <= get<4>(synthesis.second))
				synthesis.first += 10;
			get<0>(synthesis.second) += l_collection[i];
			get<4>(synthesis.second)++;
		}
		else if (get<3>(synthesis.second)[i] == '2')
		{
			if (1 <= get<5>(synthesis.second))
				synthesis.first += 10;
			get<1>(synthesis.second) += l_collection[i];
			get<5>(synthesis.second)++;
		}
		if (get<3>(synthesis.second)[i] == '3')
		{
			if (1 <= get<6>(synthesis.second))
				synthesis.first += 10;
			get<2>(synthesis.second) += l_collection[i];
			get<6>(synthesis.second)++;
		}
	}
}

void Magic1(pair<int, tuple<int, int, int, string, int, int, int>>& synthesis, int a, int b, int c)
{
	synthesis.first += (abs(get<0>(synthesis.second) - a) + abs(get<1>(synthesis.second) - b) + abs(get<2>(synthesis.second) - c));
}

int CheckMin(int n, vector<pair<int, tuple<int, int, int, string, int, int, int>>>& synthesis_collection)
{
	for (const auto & elm : synthesis_collection)
	{
		if (get<3>(elm.second).find_first_of('1') == std::string::npos ||
			get<3>(elm.second).find_first_of('2') == std::string::npos ||
			get<3>(elm.second).find_first_of('3') == std::string::npos)
			continue;

		if (n <= get<4>(elm.second))
			continue;

		return elm.first;
	}

	return 0;
}

int main()
{
	int n; cin >> n;
	int a; cin >> a;
	int b; cin >> b;
	int c; cin >> c;

	vector<int> l_collection;
	NyaGadgetVector::InputStream(l_collection, n);
	
	NyaGadgetPositionalNotation np(4);

	// pair<mp, tuple<a, b, c, np, a_time, b_times, c_times>>
	vector<pair<int, tuple<int, int, int, string, int, int ,int>>> synthesis_collection((int)pow(4, n));
	loop(i, (int)pow(4, n))
	{
		synthesis_collection[i].first = 0;
		get<3>(synthesis_collection[i].second) = np.GetN(n);
		Magic10(synthesis_collection[i], l_collection);
		Magic1(synthesis_collection[i], a, b, c);
		np++;
	}
	
	sort(synthesis_collection.begin(), synthesis_collection.end());
	cout << CheckMin(n, synthesis_collection);

	return 0;
}


Measured memory_bytes: 6400