#include <bits/stdc++.h>
using namespace std;
const static int MOD = 1000000000 + 7;
const static long long int INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> bamboo_length(n);
  for (int i = 0; i < n; ++i) cin >> bamboo_length[i];
  long long int needed_iteration = 0;
  for (int i = 0; i < n; ++i) needed_iteration += pow(4, i);
  needed_iteration *= 3;
  int ans = 1000000000;
  for (int bit = 0; bit < needed_iteration + 1; ++bit) {
    long long int tmp_bit = bit;
    list<int> com;
    while (1) {
      com.push_back(tmp_bit % 4);
      tmp_bit /= 4;
      if (tmp_bit == 0) break;
    }
    if (com.size() < n) {
      int needed_add_0 = com.size();
      for (int i = 0; i < n - needed_add_0; ++i) {
        com.push_front(0);
      }
    }
    int len_a = 0, len_b = 0, len_c = 0;
    int cnt_a = 0, cnt_b = 0, cnt_c = 0;
    int i = 0;
    for (auto itr = com.begin(); itr != com.end(); ++itr) {
      if (*itr == 0) len_a += bamboo_length[i], ++cnt_a;
      if (*itr == 1) len_b += bamboo_length[i], ++cnt_b;
      if (*itr == 2) len_c += bamboo_length[i], ++cnt_c;
      ++i;
    }
    if (len_a == 0 || len_b == 0 || len_c == 0) continue;
    ans = min(ans, abs(a - len_a) + abs(b - len_b) + abs(c - len_c) +
                       10 * (cnt_a - 1 + cnt_b - 1 + cnt_c - 1));
  }
  cout << ans << endl;
  return 0;
}
