#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932;
const double EPS = 1e-15;
const int INF = 1001001001;
const long long mod = 1e+9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<long long> len(3);
  for (int i = 0; i < 3; ++i) cin >> len[i];
  vector<long long> l(n);
  int limit = 1;
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
    limit *= 4;
  }
  long long res = INF;
  for (int i = 0; i < limit; ++i) {
    int foo = i;
    int id = 0;
    vector<vector<int>> hoge(4);
    while (foo > 0) {
      hoge[foo % 4].push_back(l[id++]);
      foo /= 4;
    }
    if (hoge[0].size() == 0 || hoge[1].size() == 0 || hoge[2].size() == 0)
      continue;
    long long score = 0;
    for (int s = 0; s < 3; ++s) {
      long long sum = accumulate(hoge[s].begin(), hoge[s].end(), 0ll);
      score += 10ll * (hoge[s].size() - 1);
      score += abs(len[s] - sum);
    }
    res = min(res, score);
  }
  cout << res << endl;
}
