var input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
var head = input.shift().split(' ');

var n = +head[0];
var a = +head[1];
var b = +head[2];
var c = +head[3];

var l = input.filter(s => s).map(s => +s);
var min = 10000;

for (var i1 = 0; i1 < n - 2; i1++) {
  for (var i2 = i1; i2 < n - 1; i2++) {
    for (var i3 = i2; i3 < n; i3++) {
      var t = l.slice(0);
      var l3 = t.splice(i3, 1)[0];
      var l2 = t.splice(i2, 1)[0];
      var l1 = t.splice(i1, 1)[0];
      make(l1, l2 ,l3, t, 0);
    }
  }
}

console.log(min);

function make(i, j, k, l, cost) {
  var s = [i, j, k].sort((a, b) => b - a);
  var sum = cost + Math.abs(a - s[0]) + Math.abs(b - s[1]) + Math.abs(c - s[2]);
  if (sum < min) {
    min = sum;
  }
  if (l.length > 0) {
    for (var x = 0; x < l.length; x++) {
      var t = [...l.slice(0, x), ...l.slice(x + 1)];
      make(i + l[x], j, k, t, cost + 10);
      make(i, j, k + l[x], t, cost + 10);
      make(i, j, k + l[x], t, cost + 10);
    }
  }
}