package main

import "fmt"

func main() {
	var N int
	ends := make([]int, 3)
	fmt.Scanf("%d %d %d %d", &N, &ends[0], &ends[1], &ends[2])

	bars := make([]int, N)
	for i := range bars {
		fmt.Scanf("%d", &bars[i])
	}

	groups := make([]int, N)
	ans := pick(ends, bars, 0, groups)
	fmt.Println(ans)
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

const maxInt = 99999999

func pick(ends, bars []int, i int, groups []int) int {
	if i == len(bars) {
		cur := make([]int, 4)
		joint := 0
		for n := range bars {
			if groups[n] != 3 {
				if cur[groups[n]] > 0 {
					joint += 10
				}
			}
			cur[groups[n]] += bars[n]
		}
		if cur[0] == 0 || cur[1] == 0 || cur[2] == 0 {
			return maxInt
		}

		ans := abs(cur[0]-ends[0]) +
			abs(cur[1]-ends[1]) +
			abs(cur[2]-ends[2]) +
			joint
		fmt.Println(groups, ans)
		return ans
	}

	min := maxInt
	for g := 0; g < 4; g++ {
		groups[i] = g
		n := pick(ends, bars, i+1, groups)
		if n < min {
			min = n
		}
	}
	return min
}
