<?php

fscanf(STDIN, "%d %d %d %d", $n, $A, $B, $C);
for($i = 0; $i < $n; $i++){
    $l[] = trim(fgets(STDIN));
}

o($l);

echo dfs(0,0,0,0) - 30;

function dfs($pos, $a, $b, $c){
    global $n, $l, $A, $B, $C;
    if($pos == $n){
        if(min($a, $b, $c) == 0){
            return 999999;
        }else{
            return abs($a-$A) + abs($b-$B) + abs($c-$C);
        }
        return 0;
    }
    $v[] = dfs($pos + 1, $a, $b, $c);
    $v[] = dfs($pos + 1, $a + $l[$pos], $b, $c) + 10;
    $v[] = dfs($pos + 1, $a, $b + $l[$pos], $c) + 10;
    $v[] = dfs($pos + 1, $a, $b, $c + $l[$pos]) + 10;
    return min($v);
}