// Original C++ solution (slower):
#define _USE_MATH_DEFINES

#include<cstdio>

#include <cstring>

#include <cmath>

#include <cstdlib>

#include <deque>

#include <algorithm>

#include <functional>

#include <iostream>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <utility>

#include <vector>

#include <iterator>

#include<iomanip>



using namespace std;



#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)

#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)

#define all(c) begin(c),end(c)



#define int ll

#define SZ(x) ((int)(x).size())

#define pb push_back

#define mp make_pair



typedef long long ll;

//typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef pair<ll, int> pli;

typedef pair<double, double> pdd;

typedef vector<vector<int>> mat;

//typedef unsigned int uint;



template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }

template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }



const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;

const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;



signed main()

{

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, A[3], L[10];



	cin >> N;

	rep(i, 0, 3)cin >> A[i];

	rep(i, 0, N)cin >> L[i];

	sort(L, L + N);



	int ans = INF;

	rep(i, 0, (int)(pow(3, N)))

	{

		vector<int> s[3];



		int ti = i;

		rep(j, 0, N)

		{

			s[ti % 3].push_back(j);

			ti /= 3;

		}



		sort(A, A + 3);

		do {

			int res = 0;

			rep(j, 0, 3)

			{

				int bk = 0;

				rep(k, 0, SZ(s[j]))

				{

					if (A[j] <= L[s[j][k]])

					{

						bk = k;

						break;

					}

					if (k == SZ(s[j]) - 1)

					{

						bk = k + 1;

					}

				}



				int rres = INF;

				if (bk < SZ(s[j]))

				{

					rres = L[s[j][bk]] - A[j];

				}

				rep(k, 0, 1LL << bk)

				{

					int sum = 0;

					int sumn = 0;

					rep(l, 0, bk)

					{

						if ((k&(1LL << l)))

						{

							sum += L[s[j][l]];

							sumn++;

						}

					}

					if (sumn > 0)

					{

						chmin(rres, (sumn - 1) * 10 + abs(sum - A[j]));

					}

				}

				res += rres;

			}

			chmin(ans, res);

		} while (next_permutation(A, A + 3));

	}



	cout << ans << endl;



	return 0;

}

// Optimized solution to the same problem (faster):
#define _USE_MATH_DEFINES

#include<cstdio>

#include <cstring>

#include <cmath>

#include <cstdlib>

#include <deque>

#include <algorithm>

#include <functional>

#include <iostream>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <utility>

#include <vector>

#include <iterator>

#include<iomanip>



using namespace std;



#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)

#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)

#define all(c) begin(c),end(c)



#define int ll

#define SZ(x) ((int)(x).size())

#define pb push_back

#define mp make_pair



typedef long long ll;

//typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef pair<ll, int> pli;

typedef pair<double, double> pdd;

typedef vector<vector<int>> mat;

//typedef unsigned int uint;



template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }

template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }



const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;

const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;



signed main()

{

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, A[3], L[10];



	cin >> N;

	rep(i, 0, 3)cin >> A[i];

	rep(i, 0, N)cin >> L[i];

	sort(L, L + N);



	int ans = INF;

	rep(i, 0, (int)(pow(4, N)))

	{

		int ss[3] = { 0 };

		int sum[3] = { 0 };

		int ti = i;

		rep(j, 0, N)

		{

			if (ti % 4 != 3)

			{

				ss[ti % 4]++;

				sum[ti % 4] += L[j];

			}

			ti /= 4;

		}



		if (ss[0] == 0 || ss[1] == 0 || ss[2] == 0)continue;



		int res = 0;

		rep(j, 0, 3)

		{

			res += (ss[j] - 1) * 10 + abs(sum[j] - A[j]);

		}

		chmin(ans, res);

	}



	cout << ans << endl;



	return 0;

}

// Fastest known solution for this problem: