#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>
#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 1000000007;
const ll INF = 0x3F3F3F3F;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline T Ckmax(T &x, T y)
{
    return x = std::max(x, y);
}
template <typename T>
inline T Ckmin(T &x, T y)
{
    return x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll read(void)
{
    char x;
    while (x = getchar(), x != '-' && !isdigit(x))
        ;
    char flg = x == '-';
    ll num = (flg ? getchar() : x) - '0';
    while (isdigit(x = getchar()))
        ((num *= 10) += x - '0') %= MOD;
    return flg ? -num : num;
}
const int N = 8 + 10;
int d[N], e[N], ans = INT_MAX;
int f[N];
int n;
void dfs(int x)
{
	if (x > n)
	{
		int sum[4] = {0}, cnt[4] = {0};
		for (int i = 1; i <= n; ++i)
		{
			sum[f[i]] += d[i];
			++cnt[f[i]];
		}
		int tmp = 0;
		for (int i = 1; i <= 3; ++i)
			if (!cnt[i])
				return ;
		if (sum[1] == 98 && sum[2] == 91 && sum[3] == 80)
			tmp =0;
		for (int i = 1; i <= 3; ++i)
		{
			tmp += 10 * (cnt[i] - 1) + Abs(e[i] - sum[i]);
			/*
			if (sum[i] > e[i])
			{
				if ((sum[i] - e[i]) % 2)
					tmp += (sum[i] - e[i]) / 2 + 2;
				else
					tmp += (sum[i] - e[i]) / 2;
			}
			else
				tmp += e[i] - sum[i];
				*/
		}
		Ckmin(ans, tmp);
		return ;
	}
	for (int i = 0; i <= 3; ++i)
	{
		f[x] = i;
		dfs(x + 1);
	}
}
int main()
{
	cinspu();
	std::cin >> n;
	for (int i = 1; i <= 3; ++i)
		std::cin >> e[i];
	for (int i = 1; i <= n; ++i)
		std::cin >> d[i];
	dfs(1);
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256