#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
lli mod197 = 1000000007LL;
template <typename T>
T extgcd(T a, T b, T& x, T& y) {
  T d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
struct bamboo {
  int a;
  int b;
  int c;
};
bool operator<(const bamboo& left, const bamboo& right) {
  if (left.a == right.a && left.b == right.b) return left.c < right.c;
  if (left.a == right.a) return left.b < right.b;
  return left.a < right.a;
}
lli l[10] = {};
int main(void) {
  std::map<bamboo, int> m;
  std::map<bamboo, int> next_m;
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  m[bamboo{0, 0, 0}] = 100;
  for (int i = 0; i < N; i++) {
    for (auto itr = m.begin(); itr != m.end(); itr++) {
      {
        bamboo b = itr->first;
        int cost = itr->second;
        b.a += l[i];
        if (next_m[b] == 0)
          next_m[b] = cost;
        else
          next_m[b] = std::min(next_m[b], cost);
      }
      {
        bamboo b = itr->first;
        int cost = itr->second;
        b.b += l[i];
        if (next_m[b] == 0)
          next_m[b] = cost;
        else
          next_m[b] = std::min(next_m[b], cost);
      }
      {
        bamboo b = itr->first;
        int cost = itr->second;
        b.c += l[i];
        if (next_m[b] == 0)
          next_m[b] = cost;
        else
          next_m[b] = std::min(next_m[b], cost);
      }
      {
        bamboo b = itr->first;
        int cost = itr->second;
        next_m[b] = cost;
      }
    }
    swap(m, next_m);
  }
  int ans = 10000000;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    if (itr->first.a == 0 || itr->first.b == 0 || itr->first.c == 0) continue;
    ans = std::min(ans, itr->second - 100 + abs(itr->first.a - A) +
                            abs(itr->first.b - B) + abs(itr->first.c - C));
  }
  std::cout << ans << std::endl;
  return 0;
}
