import sys
import heapq
import re
from heapq import heapify, heappop, heappush
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# ここから書き始める
def dfs(n, i, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt):
    if i == n:
        global ans
        if a_cnt == 0 or b_cnt == 0 or c_cnt == 0:
            return
        a_cost = abs(a - a_total) + max(0, (a_cnt - 1) * 10)
        b_cost = abs(b - b_total) + max(0, (b_cnt - 1) * 10)
        c_cost = abs(c - c_total) + max(0, (c_cnt - 1) * 10)
        cost = a_cost + b_cost + c_cost
        if ans > cost:
            ans = cost
        return
    dfs(n, i + 1, a_total + l[i], b_total, c_total, a_cnt + 1, b_cnt, c_cnt)
    dfs(n, i + 1, a_total, b_total + l[i], c_total, a_cnt, b_cnt + 1, c_cnt)
    dfs(n, i + 1, a_total, b_total, c_total + l[i], a_cnt, b_cnt, c_cnt + 1)
    dfs(n, i + 1, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt)

n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
ans = INF
dfs(n, 0, 0, 0, 0, 0, 0, 0)
print(ans) import sys sys import heapq heapq import re re from heapq import heapify, heappop, heappush from itertools import permutations from bisect import bisect_left, bisect_right from collections import Counter, deque from fractions import gcd from math import factorial, sqrt, ceil from functools import lru_cache, reduce INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 def dfs(n, i, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt):
    if i == n:
        global ans
        if a_cnt == 0 or b_cnt == 0 or c_cnt == 0:
            return
        a_cost = abs(a - a_total) + max(0, (a_cnt - 1) * 10)
        b_cost = abs(b - b_total) + max(0, (b_cnt - 1) * 10)
        c_cost = abs(c - c_total) + max(0, (c_cnt - 1) * 10)
        cost = a_cost + b_cost + c_cost
        if ans > cost:
            ans = cost
        return
    dfs(n, i + 1, a_total + l[i], b_total, c_total, a_cnt + 1, b_cnt, c_cnt)
    dfs(n, i + 1, a_total, b_total + l[i], c_total, a_cnt, b_cnt + 1, c_cnt)
    dfs(n, i + 1, a_total, b_total, c_total + l[i], a_cnt, b_cnt, c_cnt + 1)
    dfs(n, i + 1, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt) dfs if i == n:
        global ans
        if a_cnt == 0 or b_cnt == 0 or c_cnt == 0:
            return
        a_cost = abs(a - a_total) + max(0, (a_cnt - 1) * 10)
        b_cost = abs(b - b_total) + max(0, (b_cnt - 1) * 10)
        c_cost = abs(c - c_total) + max(0, (c_cnt - 1) * 10)
        cost = a_cost + b_cost + c_cost
        if ans > cost:
            ans = cost
        return
     i == n i n global ans if a_cnt == 0 or b_cnt == 0 or c_cnt == 0:
            return
         a_cnt == 0 or b_cnt == 0 or c_cnt == 0 a_cnt == 0 or b_cnt == 0 a_cnt == 0 a_cnt 0 b_cnt == 0 b_cnt 0 c_cnt == 0 c_cnt 0 return a_cost = abs(a - a_total) + max(0, (a_cnt - 1) * 10) a_cost abs(a - a_total) + max(0, (a_cnt - 1) * 10) abs(a - a_total) abs a - a_total a a_total max(0, (a_cnt - 1) * 10) max 0 (a_cnt - 1) * 10 a_cnt - 1 a_cnt 1 10 b_cost = abs(b - b_total) + max(0, (b_cnt - 1) * 10) b_cost abs(b - b_total) + max(0, (b_cnt - 1) * 10) abs(b - b_total) abs b - b_total b b_total max(0, (b_cnt - 1) * 10) max 0 (b_cnt - 1) * 10 b_cnt - 1 b_cnt 1 10 c_cost = abs(c - c_total) + max(0, (c_cnt - 1) * 10) c_cost abs(c - c_total) + max(0, (c_cnt - 1) * 10) abs(c - c_total) abs c - c_total c c_total max(0, (c_cnt - 1) * 10) max 0 (c_cnt - 1) * 10 c_cnt - 1 c_cnt 1 10 cost = a_cost + b_cost + c_cost cost a_cost + b_cost + c_cost a_cost + b_cost a_cost b_cost c_cost if ans > cost:
            ans = cost
         ans > cost ans cost ans = cost ans cost return dfs(n, i + 1, a_total + l[i], b_total, c_total, a_cnt + 1, b_cnt, c_cnt) dfs n i + 1 i 1 a_total + l[i] a_total l[i] l i b_total c_total a_cnt + 1 a_cnt 1 b_cnt c_cnt dfs(n, i + 1, a_total, b_total + l[i], c_total, a_cnt, b_cnt + 1, c_cnt) dfs n i + 1 i 1 a_total b_total + l[i] b_total l[i] l i c_total a_cnt b_cnt + 1 b_cnt 1 c_cnt dfs(n, i + 1, a_total, b_total, c_total + l[i], a_cnt, b_cnt, c_cnt + 1) dfs n i + 1 i 1 a_total b_total c_total + l[i] c_total l[i] l i a_cnt b_cnt c_cnt + 1 c_cnt 1 dfs(n, i + 1, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt) dfs n i + 1 i 1 a_total b_total c_total a_cnt b_cnt c_cnt n n i i a_total a_total b_total b_total c_total c_total a_cnt a_cnt b_cnt b_cnt c_cnt c_cnt n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] ans = INF ans INF dfs(n, 0, 0, 0, 0, 0, 0, 0) dfs n 0 0 0 0 0 0 0 print(ans) print ans a, b, c = map(int, input().split()) map(int, input().split()) a MOD = 1000000007 1000000007 MOD def dfs(n, i, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt):
    if i == n:
        global ans
        if a_cnt == 0 or b_cnt == 0 or c_cnt == 0:
            return
        a_cost = abs(a - a_total) + max(0, (a_cnt - 1) * 10)
        b_cost = abs(b - b_total) + max(0, (b_cnt - 1) * 10)
        c_cost = abs(c - c_total) + max(0, (c_cnt - 1) * 10)
        cost = a_cost + b_cost + c_cost
        if ans > cost:
            ans = cost
        return
    dfs(n, i + 1, a_total + l[i], b_total, c_total, a_cnt + 1, b_cnt, c_cnt)
    dfs(n, i + 1, a_total, b_total + l[i], c_total, a_cnt, b_cnt + 1, c_cnt)
    dfs(n, i + 1, a_total, b_total, c_total + l[i], a_cnt, b_cnt, c_cnt + 1)
    dfs(n, i + 1, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt) def dfs(n, i, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt):
    if i == n:
        global ans
        if a_cnt == 0 or b_cnt == 0 or c_cnt == 0:
            return
        a_cost = abs(a - a_total) + max(0, (a_cnt - 1) * 10)
        b_cost = abs(b - b_total) + max(0, (b_cnt - 1) * 10)
        c_cost = abs(c - c_total) + max(0, (c_cnt - 1) * 10)
        cost = a_cost + b_cost + c_cost
        if ans > cost:
            ans = cost
        return
    dfs(n, i + 1, a_total + l[i], b_total, c_total, a_cnt + 1, b_cnt, c_cnt)
    dfs(n, i + 1, a_total, b_total + l[i], c_total, a_cnt, b_cnt + 1, c_cnt)
    dfs(n, i + 1, a_total, b_total, c_total + l[i], a_cnt, b_cnt, c_cnt + 1)
    dfs(n, i + 1, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt) dfs n, a, b, c = map(int, input().split()) map(int, input().split()) n b, c = map(int, input().split()) map(int, input().split()) b l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l INF = 1 << 60 1 << 60 INF c = map(int, input().split()) map(int, input().split()) c ans = INF INF ans
import sys
import heapq
import re
from heapq import heapify, heappop, heappush
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# ここから書き始める
def dfs(n, i, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt):
    if i == n:
        global ans
        if a_cnt == 0 or b_cnt == 0 or c_cnt == 0:
            return
        a_cost = abs(a - a_total) + max(0, (a_cnt - 1) * 10)
        b_cost = abs(b - b_total) + max(0, (b_cnt - 1) * 10)
        c_cost = abs(c - c_total) + max(0, (c_cnt - 1) * 10)
        cost = a_cost + b_cost + c_cost
        if ans > cost:
            ans = cost
        return
    dfs(n, i + 1, a_total + l[i], b_total, c_total, a_cnt + 1, b_cnt, c_cnt)
    dfs(n, i + 1, a_total, b_total + l[i], c_total, a_cnt, b_cnt + 1, c_cnt)
    dfs(n, i + 1, a_total, b_total, c_total + l[i], a_cnt, b_cnt, c_cnt + 1)
    dfs(n, i + 1, a_total, b_total, c_total, a_cnt, b_cnt, c_cnt)

n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
ans = INF
dfs(n, 0, 0, 0, 0, 0, 0, 0)
print(ans)