#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int L[N];
  for (auto &l : L) {
    cin >> l;
  }
  int min_sum = A + B + C;
  for (int i = 0; i < pow(4, N); ++i) {
    int sum = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    int a_merge = -1;
    int b_merge = -1;
    int c_merge = -1;
    int num = i;
    for (auto l : L) {
      switch (num % 4) {
        case 1:
          a += l;
          a_merge++;
          break;
        case 2:
          b += l;
          b_merge++;
          break;
        case 3:
          c += l;
          c_merge++;
          break;
      }
      num /= 4;
    }
    if (a_merge > 0) sum += a_merge * 10;
    if (b_merge > 0) sum += b_merge * 10;
    if (c_merge > 0) sum += c_merge * 10;
    sum += abs(A - a) + abs(B - b) + abs(C - c);
    min_sum = min(min_sum, sum);
  }
  cout << min_sum << '\n';
  return 0;
}
