n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9


def dfs(pos, a_tmp, b_tmp, c_tmp):
    if pos == n:
        if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
    res0 = dfs(pos+1, a_tmp, b_tmp, c_tmp)
    res1 = dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10
    res2 = dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10
    res3 = dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10
    return min(res0, res1, res2, res3)


print(dfs(0, 0, 0, 0)) 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 _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] INF = 10**9 INF 10**9 10 9 def dfs(pos, a_tmp, b_tmp, c_tmp):
    if pos == n:
        if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
    res0 = dfs(pos+1, a_tmp, b_tmp, c_tmp)
    res1 = dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10
    res2 = dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10
    res3 = dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10
    return min(res0, res1, res2, res3) dfs if pos == n:
        if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
     pos == n pos n if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
     min(a_tmp, b_tmp, c_tmp) > 0 min(a_tmp, b_tmp, c_tmp) min a_tmp b_tmp c_tmp 0 return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30 abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30 abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp) abs(a-a_tmp)+abs(b-b_tmp) abs(a-a_tmp) abs a-a_tmp a a_tmp abs(b-b_tmp) abs b-b_tmp b b_tmp abs(c-c_tmp) abs c-c_tmp c c_tmp 30 return INF INF res0 = dfs(pos+1, a_tmp, b_tmp, c_tmp) res0 dfs(pos+1, a_tmp, b_tmp, c_tmp) dfs pos+1 pos 1 a_tmp b_tmp c_tmp res1 = dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10 res1 dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10 dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp) dfs pos+1 pos 1 a_tmp+l[pos] a_tmp l[pos] l pos b_tmp c_tmp 10 res2 = dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10 res2 dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10 dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp) dfs pos+1 pos 1 a_tmp b_tmp+l[pos] b_tmp l[pos] l pos c_tmp 10 res3 = dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10 res3 dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10 dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos]) dfs pos+1 pos 1 a_tmp b_tmp c_tmp+l[pos] c_tmp l[pos] l pos 10 return min(res0, res1, res2, res3) min(res0, res1, res2, res3) min res0 res1 res2 res3 pos pos a_tmp a_tmp b_tmp b_tmp c_tmp c_tmp print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 INF = 10**9 10**9 INF def dfs(pos, a_tmp, b_tmp, c_tmp):
    if pos == n:
        if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
    res0 = dfs(pos+1, a_tmp, b_tmp, c_tmp)
    res1 = dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10
    res2 = dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10
    res3 = dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10
    return min(res0, res1, res2, res3) def dfs(pos, a_tmp, b_tmp, c_tmp):
    if pos == n:
        if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
    res0 = dfs(pos+1, a_tmp, b_tmp, c_tmp)
    res1 = dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10
    res2 = dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10
    res3 = dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10
    return min(res0, res1, res2, res3) dfs l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l n, a, b, c = map(int, input().split()) map(int, input().split()) n a, b, c = map(int, input().split()) map(int, input().split()) a b, c = map(int, input().split()) map(int, input().split()) b c = map(int, input().split()) map(int, input().split()) c
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9


def dfs(pos, a_tmp, b_tmp, c_tmp):
    if pos == n:
        if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
    res0 = dfs(pos+1, a_tmp, b_tmp, c_tmp)
    res1 = dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10
    res2 = dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10
    res3 = dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10
    return min(res0, res1, res2, res3)


print(dfs(0, 0, 0, 0))
