#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
 
using namespace std;
 
int n, a, b, c;
vector<int> l;
 
int inf = 1e9;
 
int dfs(int v, int aa, int bb, int cc, const vector<int>& l)
{
    int ret = inf;
    if (v == n)
    {
        if (aa > 0 && bb > 0 && cc > 0)
        {
            return (abs(a - aa) + abs(b - bb) + abs(c - cc) - 30);
        }
        return ret;
    }
    for (int i = 0; i < 4; ++i)
    {
        if (i == 0)
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc, l));
        }
        else if (i == 1)
        {
            ret = min(ret, dfs(v + 1, aa + l[v], bb, cc, l) + 10);
        }
        else if (i == 2)
        {
            ret = min(ret, dfs(v + 1, aa, bb + l[v], cc, l) + 10);
        }
        else
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc + l[v], l) + 10);
        }
    }
    
    return ret;
}
 
int main() {
    
    cin >> n >> a >> b >> c;
    
    l = vector<int>(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> l[i];
    }
    
    int ret = dfs(0, 0, 0, 0, l);
    
    cout << ret << endl;
    
    return 0;
}
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>

using namespace std;

int n, a, b, c;
vector<int> l;

int inf = 1e9;

int dfs(int v, int aa, int bb, int cc, const vector<int>& l)
{
    int ret = inf;
    if (v == n)
    {
        if (aa > 0 && bb > 0 && cc > 0)
        {
            return (abs(a - aa) + abs(b - bb) + abs(c - cc) - 30);
        }
        return ret;
    }
    for (int i = 0; i < n; ++i)
    {
        if (i == 0)
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc, l));
        }
        else if (i == 1)
        {
            ret = min(ret, dfs(v + 1, aa + l[v], bb, cc, l) + 10);
        }
        else if (i == 2)
        {
            ret = min(ret, dfs(v + 1, aa, bb + l[v], cc, l) + 10);
        }
        else if (i == 3)
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc + l[v], l) + 10);
        }
    }
    
    return ret;
}

int main() {
    
    cin >> n >> a >> b >> c;
    
    l = vector<int>(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> l[i];
    }
    
    int ret = dfs(0, 0, 0, 0, l);
    
    cout << ret << endl;
    
    return 0;
}

