use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: usize,
        mut com: [isize; 3],
        l: [isize; n],
    }
    com.sort_by(|a, b| b.cmp(a));
    let mut v: Vec<usize> = vec![];
    let ans = solve(0, n, &mut v, &l, &com);
    println!("{}", ans);
}

fn solve(
    index: usize,
    limit: usize,
    v: &mut Vec<usize>,
    l: &Vec<isize>,
    target: &Vec<isize>,
) -> isize {
    let mut res = isize::MAX;

    if index == limit {
        let mut cost = 0;
        let mut com = vec![0isize; 3];
        for i in 0..limit {
            match v[i] {
                0 => {
                    com[0] += l[i];
                    cost += 10;
                }
                1 => {
                    com[1] += l[i];
                    cost += 10;
                }
                2 => {
                    com[2] += l[i];
                    cost += 10;
                }
                _ => (),
            };
        }
        if com.iter().any(|x| *x == 0) {
            return isize::MAX;
        }
        com.sort_by(|a, b| b.cmp(a));
        for i in 0..3 {
            cost += (com[i] - target[i]).abs();
        }
        return cost - 30;
    }

    for i in 0..4 {
        v.push(i);
        res = cmp::min(res, solve(index + 1, limit, v, l, target));
        v.pop();
    }

    res
}
