#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c;
vector<long long> v;
long long res = INT_MAX;
void v_init() {
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
}
void calc(vector<int> tmp) {
  int tmpa = 0;
  int tmpb = 0;
  int tmpc = 0;
  long long mp = 0;
  for (int i = 0; i < int(tmp.size()); i++) {
    if (tmp[i] == 1) {
      if (tmpa != 0) mp += 10;
      tmpa += v[i];
    }
    if (tmp[i] == 2) {
      if (tmpb != 0) mp += 10;
      tmpb += v[i];
    }
    if (tmp[i] == 3) {
      if (tmpc != 0) mp += 10;
      tmpc += v[i];
    }
  }
  mp += abs(tmpa - a);
  mp += abs(tmpb - b);
  mp += abs(tmpc - c);
  res = min(res, mp);
}
void dfs(int which, vector<int> tmp, int step) {
  tmp.push_back(which);
  if (step == n - 1) {
    calc(tmp);
    return;
  }
  dfs(0, tmp, step + 1);
  dfs(1, tmp, step + 1);
  dfs(2, tmp, step + 1);
  dfs(3, tmp, step + 1);
}
int main() {
  cin >> n >> a >> b >> c;
  v_init();
  vector<int> tmp;
  for (int i = 0; i < 4; i++) {
    dfs(i, tmp, 0);
  }
  cout << res << endl;
}
