#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[10], bel[10];
int b1[10], b2[10], b3[10], tag[10], cnt1, cnt2, cnt3;
int n, A, B, C;
int ans = INF;
inline int work(int id) {
    memset(tag, 0, sizeof tag);
    if (id == 1) {
        if (cnt1 == 0) return INF;
        int curm = INF;
        for (int i = 0; i < (1 << cnt1); ++i) {
            memset(tag, 0, sizeof tag);
            for (int j = 0; j < cnt1; ++j) if ((i >> j) & 1) tag[j + 1] = 1;
            int ad = 0, mx = 0, v1 = INF, used = 0;
            for (int j = 1; j <= cnt1; ++j) {
                if (!tag[j]) v1 = min(v1, abs(A - a[ b1[j] ]));
                else {
                    ad += a[b1[j]];
                    used += 10;
                }
            }
            if (used) used -= 10;
            if (i == 0) curm = min(curm, v1);
            else
            curm = min(curm, min(v1, abs(A - ad) + used));
        }
        return curm;
    }

    if (id == 2) {
        if (cnt2 == 0) return INF;
        int curm = INF;
        for (int i = 0; i < (1 << cnt2); ++i) {
            memset(tag, 0, sizeof tag);
            for (int j = 0; j < cnt2; ++j) if ((i >> j) & 1) tag[j + 1] = 1;
            int ad = 0, mx = 0, v1 = INF, used = 0;
            for (int j = 1; j <= cnt2; ++j) {
                if (!tag[j]) v1 = min(v1, abs(B - a[ b2[j] ]));
                else {
                    ad += a[b2[j]];
                    used += 10;
                }
            }
            if (used) used -= 10;
            if (i == 0) curm = min(curm, v1);
            else
            curm = min(curm, min(v1, abs(B - ad) + used));
        }
        return curm;
    }

    if (id == 3) {
        if (cnt3 == 0) return INF;
        int curm = INF;
        for (int i = 0; i < (1 << cnt3); ++i) {
            memset(tag, 0, sizeof tag);
            for (int j = 0; j < cnt3; ++j) if ((i >> j) & 1) tag[j + 1] = 1;
            int ad = 0, mx = 0, v1 = INF, used = 0;
            for (int j = 1; j <= cnt3; ++j) {
                if (!tag[j]) v1 = min(v1, abs(C - a[ b3[j] ]));
                else {
                    ad += a[b3[j]];
                    used += 10;
                }
            }
            if (used) used -= 10;
            if (i == 0) curm = min(curm, v1);
            else
            curm = min(curm, min(v1, abs(C - ad) + used));
        }
        return curm;
    }
}
int coun = 0;
inline void solve() {
    cnt1 = cnt2 = cnt3 = 0;
    int bt1 = INF, bt2 = INF, bt3 = INF;
    for (int i = 1; i <= n; ++i) {
        if (bel[i] == 1) { if (a[i] > A) bt1 = min(bt1, a[i] - A); b1[++cnt1] = i;}
        if (bel[i] == 2) { if (a[i] > B) bt2 = min(bt2, a[i] - B); b2[++cnt2] = i;}
        if (bel[i] == 3) { if (a[i] > C) bt3 = min(bt3, a[i] - C); b3[++cnt3] = i;}
        //printf("%d ", bel[i]);
    }
    //printf("\n");
    if (cnt1 == 0 || cnt1 > n - 2 || cnt2 == 0 || cnt2 > n - 2 || cnt3 == 0 || cnt3 > n - 2) return ;
    int val1 = work(1), val2 = work(2), val3 = work(3);
    //printf("f = %d %d %d %d %d %d %d\n", val1, bt1, val2, bt2, val3, bt3,min(val1, bt1) + min(val2, bt2) + min(val3, bt3));
    ans = min(ans, min(val1, bt1) + min(val2, bt2) + min(val3, bt3));
}
inline void dfs(int step) {
    if (step > n) {solve(); return ;}
    bel[step] = 1; dfs(step + 1);
    bel[step] = 2; dfs(step + 1);
    bel[step] = 3; dfs(step + 1);
}
int main() {
    //freopen("data.out", "w", stdout);
    scanf("%d %d %d %d", &n, &A, &B, &C);
    for (int i = 1; i <= n; ++i)scanf("%d", &a[i]);
    dfs(1);
    printf("%d\n", ans);//printf("%d\n", coun);
    return 0;
}


Measured memory_bytes: 256