#include <bits/stdc++.h>
using namespace std;
const int N = 10;
vector<int> L(N);
int n, a, b, c;
vector<char> C = {'0', 'A', 'B', 'C'};
vector<string> S;
void dfs(int now, string str) {
  for (int i = 0; i < 4; i++) {
    if (now == n) {
      vector<bool> F(3, false);
      for (int j = 0; j < n; j++) {
        if (str[j] == 'A')
          F[0] = true;
        else if (str[j] == 'B')
          F[1] = true;
        else if (str[j] == 'C')
          F[2] = true;
      }
      int cnt = count(F.begin(), F.end(), true);
      if (cnt == 3) {
        S.push_back(str + C[i]);
      }
    } else
      dfs(now + 1, str + C[i]);
  }
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) {
    cin >> L[i];
  }
  dfs(0, "");
  int ans = 1e9;
  int ss = S.size();
  for (int i = 0; i < ss; i++) {
    int mp = 0;
    int a_total = 0, b_total = 0, c_total = 0;
    int a_cnt = 0, b_cnt = 0, c_cnt = 0;
    for (int j = 0; j < n; j++) {
      if (S[i][j] == '0')
        ;
      else if (S[i][j] == 'A') {
        a_total += L[j];
        a_cnt++;
      } else if (S[i][j] == 'B') {
        b_total += L[j];
        b_cnt++;
      } else if (S[i][j] == 'C') {
        c_total += L[j];
        c_cnt++;
      }
    }
    mp += max(0, a_cnt - 1) * 10 + max(0, b_cnt - 1) * 10 + max(0, c_cnt - 1);
    mp += abs(a - a_total);
    mp += abs(b - b_total);
    mp += abs(c - c_total);
    ans = min(ans, mp);
  }
  cout << ans << endl;
  return 0;
}
