#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Tu = tuple<int, int, int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> def(3);
  for (int i = 0; i < (3); ++i) cin >> def[i];
  vector<int> ary(n);
  for (int i = 0; i < (n); ++i) cin >> ary[i];
  stack<pair<vector<int>, int> > s;
  vector<int> v(0);
  s.push(make_pair(v, 0));
  int ans = 1e9;
  while (!s.empty()) {
    pair<vector<int>, int> p = s.top();
    s.pop();
    if (p.second == n) {
      vector<int> cnt(3, 0), tree = p.first;
      int cost = 0;
      for (int i = 0; i < (n); ++i) {
        if (tree[i] != 3) {
          cnt[tree[i]] += ary[i];
          cost += 10;
        }
      }
      for (int i = 0; i < (3); ++i) {
        cost += abs(cnt[i] - def[i]);
      }
      cost = max(cost - 30, 0);
      ans = min(ans, cost);
    }
    if (p.second < n) {
      for (int i = 0; i < (4); ++i) {
        vector<int> nv = p.first;
        nv.emplace_back(i);
        s.push(make_pair(nv, p.second + 1));
      }
    }
  }
  cout << ans << endl;
}
