#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int MAX_N = 8;
int N, A, B, C;
vector<int> l(MAX_N);

int dfs(int depth, int a, int b, int c) {
    if(depth == N) {
        if(a == 0 || b == 0 || c == 0) {
            return 99999999;
        }
        return abs(a-A) + abs(b-B) + abs(c-C) - 30; 
    }
    else {
        int notUse = dfs(depth+1, a, b, c);
        int useForA = dfs(depth+1, a+l[depth], b, c);
        int useForB = dfs(depth+1, a, b+l[depth], c);
        int useForC = dfs(depth+1, a, b, c+l[depth]);
        return min({notUse, useForA, useForB, useForC});
    }
}

int main() {
    cin >> N >> A >> B >> C;
    reo(i, n) {
        cin >> l[i];
    }

    cout << dfs(0, 0, 0, 0);

    cout << endl;
    return 0;
}