#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e14;

int n, a, b, c;

void list(int k, vector<int> &L) {
  L.resize(n);
  rep(i, n) {
    L[i] = k % 4;
    k /= 4;
  }
}

void Main() {
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int num = 1;
  rep(_, n) num *= 4;
  int ans = 1000000;
  vector<int> M;
  rep(k, num) {
    list(k, M);
    int x, y, z;
    x = y = z = 0;
    int score = 0;
    rep(i, n) {
      if (M[i] == 0) {
        if (x > 0) score += 10;
        x += l[i];
      } else if (M[i] == 1) {
        if (y > 0) score += 10;
        y += l[i];
      } else if (M[i] == 2) {
        if (z > 0) score += 10;
        z += l[i];
      }
    }
    if (x == 0 || y == 0 || z == 0) continue;
    score += abs(a - x) + abs(b - y) + abs(c - z);
    ans = min(score, ans);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
