#include <bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int>l;
vector<int>sentaku[4];
long long ans = 0;
void dfs(int n) {
    if(n == N) {
        if(sentaku[0] > 0 && sentaku[1] > 0 && sentaku[2] > 0) {
            int cnt1 = 0;
            int cnt2 = 0;
            int cnt3 = 0;
            for(int i = 0; i < sentaku[0].size(); i++) {
                cnt1+=sentaku[0][i];
            }
            for(int i = 0; i < sentaku[1].size(); i++) {
                cnt2+=sentaku[1][i];
            }
            for(int i = 0; i < sentaku[2].size(); i++) {
                cnt3+=sentaku[2][i];
            }
            ans = min(abs(A-cnt1)+abs(B-cnt2)+abs(C-cnt3),ans);
        }
    }
    else {
        sentaku[0].push.back(l[n]);
        dfs(n+1);
        sentaku[1].push.back(l[n]);
        dfs(n+1);
        sentaku[2].push.back(l[n]);
        dfs(n+1);
        sentaku[3].push.back(l[n]);
        dfs(n+1);
    }
}
int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    int res = dfs(0);
    cout << res-30 << endl;
}


