#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll mod=1e9+7;
int inf = 1e6;

int n;
int a,b,c;
vector<int> l(8);

int dfs(int j, int ta, int tb, int tc) {
    if (j==n) {
        if (ta>0 && tb>0 && tc>0) return abs(a-ta)+abs(b-tb)+abs(c-tc)-30;
        else return inf;
    }
    int resa=dfs(j+1,ta+l[j],tb,tc)+10;
    int resb=dfs(j+1,ta,tb+l[j],tc)+10;
    int resc=dfs(j+1,ta,tb,tc+l[j])+10;
    int res=dfs(j+1,ta,tb,tc);
    return min(min(resa,resb),min(resc,res));
}

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