#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a, b, c) = scan!(usize, i64, i64, i64);
    let vs = scan!(i64;;n);

    let mut ans = 1 << 30;
    for i in 0..1 << (2 * n) {
        let mut comb = 0;
        let (mut a0, mut b0, mut c0) = (0, 0, 0);
        for j in 0..n {
            let pat = (i >> (2 * j)) & 0x03;
            match pat {
                0 => {
                    a0 += vs[j][0];
                    comb += 10;
                }
                1 => {
                    b0 += vs[j][0];
                    comb += 10;
                }
                2 => {
                    c0 += vs[j][0];
                    comb += 10;
                }
                _ => (),
            }
        }
        if a0 == 0 || b0 == 0 || c0 == 0 {
            continue;
        }
        ans = ans.min(comb - 30 + (a - a0).abs() + (b - b0).abs() + (c - c0).abs())
    }
    println!("{}", ans);
}
