use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: usize = iter.parse();
    let dest: Vec<i32> = (0..3).map(|_| iter.parse()).collect();
    let ls: Vec<i32> = (0..n).map(|_| iter.parse()).collect();
    let all = 4_u32.pow(n as u32);

    let mut v = Vec::new();
    for i in 0..all {
        let mut base = i as i32;
        let mut mp = 0;
        let mut current = vec![0_i32; 3];
        for j in 0..n {
            for k in 0..3 {
                if base % 4 == k as i32 {
                    if current[k] != 0 {
                        mp += 10;
                    }
                    current[k] += ls[j];
                }
            }
            base /= 4;
        }
        for (x, d) in current.iter().zip(dest.iter()) {
            mp += (x - d).abs();
        }

        v.push(mp);
    }

    println!("{}", v.into_iter().min().unwrap());
}