#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long infll = 1 << 60LL;
const long long mod = 1e9 + 7;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
class Radix {
 private:
  const char* s;
  int a[128];

 public:
  Radix(const char* s = "0123") : s(s) {
    int i;
    for (i = 0; s[i]; ++i) a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if (!p) return "0";
    char t[64] = {};
    for (i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) { return to(to(t, p), q); }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for (i = 1; i < (int)t.length(); ++i) sm = sm * p + a[(int)t[i]];
    return sm;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  Radix r;
  long long n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<long long> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  long long mp = 0;
  long long max = 1;
  for (int i = 0; i < n; i++) {
    max *= 4;
  }
  long long ta = 0, tb = 0, tc = 0, td = 0;
  long long ans = 100000;
  long long cnt = 0;
  for (long long i = 0; i < max; i++) {
    bool aa = false;
    bool bb = false;
    bool cc = false;
    mp = 0;
    ta = 0;
    tb = 0;
    tc = 0;
    string st = r.to(i, 4);
    for (int j = 0; j <= n; j++) {
      if (j >= st.size() || st[j] == '0') {
      } else {
        if (st[j] == '1') {
          if (ta != 0) mp += 10;
          ta += l[j];
          aa = true;
        } else if (st[j] == '2') {
          if (tb != 0) mp += 10;
          tb += l[j];
          bb = true;
        } else if (st[j] == '3') {
          if (tc != 0) mp += 10;
          tc += l[j];
          cc = true;
        }
      }
    }
    if (aa && bb && cc) {
      mp += abs(ta - a);
      mp += abs(tb - b);
      mp += abs(tc - c);
      ans = min(ans, mp);
    }
  }
  cout << ans << endl;
  return 0;
}
