    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <iostream>
    #include <string>
    #include <vector>
    #include <map>
    #include <set>
    #include <stack>
    #include <list>
    #include <queue>
    #include <deque>
    #include <algorithm>
    #include <numeric>
    #include <utility>
    #include <complex>
    #include <functional>
    #include <climits>

    using namespace std;
    int N, A, B, C, m = INT_MAX;
    vector<int> take;

    int calc(vector<int> v)
    {
        int a = 0, b = 0, c = 0, mp = 0;
        for (int i = 0; i < N; i++)
        {
            if (v[i] == 0)
            {
                if (a > 0)
                {
                    mp += 10;
                }
                a += take[i];
            }
            else if (v[i] == 1)
            {
                if (b > 0)
                {
                    mp += 10;
                }
                b += take[i];
            }
            else if (v[i] == 2)
            {
                if (c > 0)
                {
                    mp += 10;
                }
                c += take[i];
            }
        }
        if(!a || !b || !c) {
            return INT_MAX;
        }
        mp += abs(A - a);
        mp += abs(B - b);
        mp += abs(C - c);
        return mp;
    }

    int dfs(int d, vector<int> v)
    {
        if (d == N)
        {
            return m = min(calc(v), m);
        }
        for (int i = 0; i < 4; i++)
        {
            v[d] = i;
            dfs(d + 1, v);
        }
    }

    int main()
    {
        cin >> N >> A >> B >> C;
        for (int i = 0; i < N; i++)
        {
            int l;
            cin >> l;
            take.push_back(l);
        }
        vector<int> v(N, 0);
        dfs(0, v);
        cout << m << endl;
    }#include
