#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int main() {
  int N, A[4];
  cin >> N >> A[1] >> A[2] >> A[3];
  int L[N];
  int masu[3000];
  for (int i = 0; i < 3000; i++) masu[i] = 101000;
  int MP = 0;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    masu[L[i]] = 0;
  }
  sort(L, L + N);
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (j == i) continue;
      if (masu[L[j]] == 0) {
        if (masu[L[j]]) {
          masu[L[i] + L[j]] = 10;
        }
      }
    }
  }
  for (int i = 0; i <= 1000; i++) {
    if (masu[i] == 101000) continue;
    for (int j = 0; j <= 1000; j++) {
      if (masu[j] != 101000) {
        masu[i + j] = masu[i] + masu[j] + 10;
      }
    }
  }
  for (int i = 1; i <= 3; i++) {
    int mn = 101000;
    int col = 101000;
    for (int j = 1; j <= A[i] + 300; j++) {
      if (masu[j] == 101000) continue;
      if (mn >= masu[j] + abs(j - A[i])) {
        mn = masu[j] + abs(j - A[i]);
        col = j;
      }
    }
    MP += mn;
    masu[col] = 101000;
  }
  cout << MP << endl;
}
