#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn absolute(x: i32) -> i32 {
    if x >= 0 {
        x
    } else {
        -x
    }
}

use std::cmp;

fn find_min(x: &Vec<i32>) -> i32 {
    let mut min: i32 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        min = cmp::min(*i, min);
    }
    return min;
}

fn main() {
    let init: Vec<i32> = read_vec();
    let mut l: Vec<i32> = Vec::new();

    for _i in 0..init[0] {
        let tmp: i32 = read();
        l.push(tmp);
    }

    fn mp(n: i32, a: i32, b: i32, c: i32, params: &Vec<i32>, length: &Vec<i32>) -> i32 {
        if n == params[0] {
            absolute(a - params[1]) + absolute(b - params[2]) + absolute(c - params[3]) - 30
        } else {
            let mut cost: Vec<i32> = Vec::new();
            cost.push(mp(n + 1, a, b, c, params, length));
            cost.push(mp(n + 1, a + length[n as usize], b, c, params, length) + 10);
            cost.push(mp(n + 1, a, b + length[n as usize], c, params, length) + 10);
            cost.push(mp(n + 1, a, b, c + length[n as usize], params, length) + 10);
            find_min(&cost)
        }
    }

    println!("{}", mp(0, 0, 0, 0, &init, &l));
}
