#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
int ans = 1000000007;
int N, A, B, C;
vector<int> l;
void dfs(int mp, int i, int a, int b, int c) {
  if (i == N) {
    int a1, b1, c1;
    if (a <= 0 || b <= 0 || c <= 0) return;
    int tmp = abs(A - a) + abs(B - b) + abs(C - c) + mp;
    if (ans > tmp) ans = tmp;
    return;
  }
  dfs(mp, i + 1, a, b, c);
  if (a == 0)
    dfs(mp, i + 1, a + l[i], b, c);
  else
    dfs(mp + 10, i + 1, a + l[i], b, c);
  if (b == 0)
    dfs(mp, i + 1, a, b + l[i], c);
  else
    dfs(mp + 10, i + 1, a, b + l[i], c);
  if (c == 0)
    dfs(mp, i + 1, a, b, c + l[i]);
  else
    dfs(mp + 10, i + 1, a, b + l[i], c);
}
int main() {
  cin >> N;
  cin >> A >> B >> C;
  l.resize(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> l[i];
  dfs(0, 0, 0, 0, 0);
  cout << ans << endl;
}
