use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, a, b, c): (usize, usize, usize, usize) = parse!(it, 4);
    let l: Vec<usize> = (0..n).map(|_| parse!(it)).collect();
    let mut ret = std::usize::MAX / 2;
    let diff = |x: usize, y: usize| if x >= y { x - y } else { y - x };
    for i in 0..4usize.pow(n as u32) {
        let mut p = 0;
        let mut ca = 0;
        let mut cb = 0;
        let mut cc = 0;
        let mut i = i;
        for j in 0..n {
            match i & 3 {
                1 => {
                    if ca != 0 {
                        p += 10
                    };
                    ca += l[j]
                }
                2 => {
                    if cb != 0 {
                        p += 10
                    };
                    cb += l[j]
                }
                3 => {
                    if cc != 0 {
                        p += 10
                    };
                    cc += l[j]
                }
                _ => (),
            }
            i >>= 2;
        }
        p += diff(ca, a) + diff(cb, b) + diff(cc, c);
        ret = std::cmp::min(p, ret);
    }
    println!("{}", ret);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        5 100 90 80
98
40
30
21
80
        ";
        solve(s);
    }
}
