"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input);

  const N = o.a();
  const A = o.a();
  const B = o.a();
  const C = o.a();

  const l = [];
  for (let i=0;i<N;i++) {
    l.push(o.a()); 
  }


  let minMp = Infinity;
  for (let i=0;i<Math.pow(4, N);i++) {
    let cA = [];
    let cB = [];
    let cC = [];
  
    let str = i.toString(4);
    for (let k = 0;k<N;k++) {
      if (str[k] === "1") {
        cA.push(l[k]);
      } else if (str[k] === "2") {
        cB.push(l[k]);
      } else if (str[k] === "3") {
        cC.push(l[k]);
      }
    }

    let sA = cA.length > 0 ? cA.reduce((acc,cur) => acc + cur) : 0;
    let sB = cB.length > 0 ? cB.reduce((acc,cur) => acc + cur) : 0;
    let sC = cC.length > 0 ? cC.reduce((acc,cur) => acc + cur) : 0;

    if (sA && sB && sC) {
      let mp = Math.abs(A - sA) + Math.abs(B - sB) + Math.abs(C - sC) + 10 * (Math.max(cA.length - 1, 0) + Math.max(cB.length - 1, 0) + Math.max(cC.length - 1, 0))
      if (mp < minMp) {
        minMp = mp;
      }
    }

  }
  console.log(minMp);

}


main(require("fs").readFileSync("/dev/stdin", "utf8"));
