#![allow(dead_code)]
#![allow(non_snake_case)]
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// Thanks @tanakh :bow:
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[derive(Debug)]
struct Matrix<T=f32> {
    row: usize,
    col: usize,
    matrix: Vec<Vec<T>>,
}

impl Matrix {
    fn rank(&mut self) -> usize {
        let mut rank = 0;

        for col in 0..self.col {
            let mut pivot = 1000000;
            let mut ma = 1e-10;
            for row in rank..self.row {
                if self.matrix[row][col].abs() > ma {
                    ma = self.matrix[row][col].abs();
                    pivot = row;
                }
            }
            if pivot == 1000000 {
                continue;
            }
            self.matrix.swap(pivot, rank);

            let div = self.matrix[rank][col];
            for col2 in 0..self.col { self.matrix[rank][col2] /= div; }
            for row in 0..self.row {
                if row != rank && self.matrix[row][col].abs() > 1e-10 {
                    let fac = self.matrix[row][col];
                    for col2 in 0..self.col {
                        self.matrix[row][col2] -= self.matrix[rank][col2] * fac;
                    }
                }
            }
            rank += 1;
            // println!("---------------------");
            // println!("col {}", col);
            // println!("pivot {}, rank {}", pivot, rank);
            // println!("  swapped matrix {:?}", self.matrix);
        }
        return rank;
    }
}

#[test]
fn matrix_rank_test() {
    let mat = vec![vec![4.0, 2.0, 3.0, 4.0],
                   vec![1.0, 2.0, 3.0, 4.0],
                   vec![0.0, 0.0, 0.0, 0.0]];
    assert_eq!(2, rank(&mat, false));
}

#[test]
fn matrix_rank_test2() {
    let mat = vec![vec![1.0, 1.0],
                   vec![1.0, 0.0],
                   vec![0.0, 1.0]];
    assert_eq!(2, rank(&mat, false));
}
#[test]
fn matrix_solve_test() {
    let mat = vec![vec![4.0, 2.0, 3.0, 4.0],
                   vec![1.0, 2.0, 3.0, 4.0],
                   vec![0.0, 0.0, 0.0, 0.0]];
    let b = vec![0.0, 0.0, 0.0, 0.0];
    assert_eq!(2, solve(mat, b));
}

#[test]
fn matrix_solve_test2() {
    let mat = vec![vec![1.0, 1.0],
                   vec![1.0, 0.0],
                   vec![0.0, 1.0]];
    let b = vec![0.0, 0.0, 0.0, 0.0];
    assert_eq!(2, solve(mat, b));
}
fn gcd(a: i64, b: i64) -> i64 {
    if a < b { return gcd(b, a); }
    // let q = a/b;
    let r = a%b;
    if r == 0 { return b; }
    return gcd(b, r);
}

fn chars_to_str(v: Vec<char>) -> String {
    return v.into_iter().collect();
}

#[test]
fn test_chars_to_str() {
    let c = vec!['a','b'];
    let actual = chars_to_str(c);
    assert_eq!(actual, "ab");
}

fn dfs(i:usize, a:i32, b:i32, c:i32, l: &Vec<i32>) -> i32 {
    if i == l.len() {
        return
            if *[a,b,c].iter().min().unwrap() > 0 {
                unsafe { (a-A).abs() + (b-B).abs() + (c-C).abs() - 30 }
            } else {
                10_i32.pow(9)
            }
    }

    let aa = dfs(i+1, a+l[i], b,      c,      l) + 10;
    let bb = dfs(i+1, a,      b+l[i], c,      l) + 10;
    let cc = dfs(i+1, a,      b,      c+l[i], l) + 10;
    let dd = dfs(i+1, a,      b,      c,      l);

    return *[aa, bb, cc, dd].iter().min().unwrap();
}

fn dfs2(i: usize, v: &mut Vec<i32>, l: &Vec<i32>) {
    unsafe {
        if i == N { calc(v, l); return; }
    }
    for j in 0..4 {
        v[i] = j;
        dfs2(i+1, v, l);
    }
}

fn mp(pp_cnt:i32, pp:i32, P:i32) -> i32 {
    return (pp_cnt-1)*10 + (pp-P).abs();
}

fn calc(v: &Vec<i32>, l: &Vec<i32>) {

    let mut aa = 0;
    let mut bb = 0;
    let mut cc = 0;
    let mut aa_cnt = 0;
    let mut bb_cnt = 0;
    let mut cc_cnt = 0;
    // 0 -> A, 1->B, 2 -> C, 3 -> nothing
    for (i, value) in v.iter().enumerate() {
        if *value == 0 { aa += l[i]; aa_cnt += 1; }
        if *value == 1 { bb += l[i]; bb_cnt += 1; }
        if *value == 2 { cc += l[i]; cc_cnt += 1; }
    }
    unsafe {
        let mp =  mp(aa_cnt, aa, A) + mp(bb_cnt, bb, B) + mp(cc_cnt, cc, C);
        if aa_cnt == 0 || bb_cnt == 0 || cc_cnt == 0 { return; }
        // println!("aa {} bb {} cc {} mp {} v {:?} ", aa,bb,cc,mp,v);
        if ANS > mp { ANS = mp;  }
    }
}

static mut A: i32 = 0;
static mut B: i32 = 0;
static mut C: i32 = 0;
static mut N: usize = 0;
static mut ANS: i32 = 1_000_000_000;
fn main() {
    input! { n:usize, a:i32, b:i32, c:i32, l:[i32;n] }

    unsafe { A = a; B = b; C = c; N = n; }

    // println!("{}", dfs(0, 0, 0, 0, &l));

    // let mut v = vec![-1; n];
    // dfs2(0, &mut v, &l);
    // unsafe {
    //     println!("{}", ANS);
    // }

    for i in 0..1<<2*n {
        let mut v = vec![-1; n];
        for j in 0..n {
            v[j] = i>>2*j & 3;
        }
        // println!("{:?}", v);
        calc(&v, &l);
    }
    unsafe {
        println!("{}", ANS);
    }
}


Measured memory_bytes: 4352