#include <bits/stdc++.h>
using namespace std;
long double PI = 3.14159265358979323846;
const long long M = 1e9 + 7;
const long long inf = 1e18;
const long long ms = 2e5 + 5;
static int fastline = []() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  return 0;
}();
;
long long n, ans, ar[9], A, B, C;
void fun(long long i, pair<long long, long long> a,
         pair<long long, long long> b, pair<long long, long long> c) {
  if (i == n) {
    long long temp = abs(a.first - A) + abs(b.first - B) + abs(c.first - C);
    if (a.second > 1) temp += (a.second - 1) * 10;
    if (b.second > 1) temp += (b.second - 1) * 10;
    if (c.second > 1) temp += (c.second - 1) * 10;
    ans = min(ans, temp);
    return;
  }
  fun(i + 1, a, b, c);
  fun(i + 1, {a.first + ar[i], a.second + 1}, b, c);
  fun(i + 1, a, {b.first + ar[i], b.second + 1}, c);
  fun(i + 1, a, b, {c.first + ar[i], c.second + 1});
}
void solve() {
  cin >> n >> A >> B >> C;
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
  }
  ans = 2e9;
  fun(0, {0, 0}, {0, 0}, {0, 0});
  cout << ans << endl;
}
int main() {
  { solve(); }
  return 0;
}
