n, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(n)]
INF = 10**9

def rec(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = rec(cur+1, a, b, c)
    ret1 = rec(cur+1, a+L[cur], b, c) + 10
    ret2 = rec(cur+1, a, b+L[cur], c) + 10
    ret3 = rec(cur+1, a, b, c+L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(rec(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 rec(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = rec(cur+1, a, b, c)
    ret1 = rec(cur+1, a+L[cur], b, c) + 10
    ret2 = rec(cur+1, a, b+L[cur], c) + 10
    ret3 = rec(cur+1, a, b, c+L[cur]) + 10
    return min(ret0, ret1, ret2, ret3) rec if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
     cur == n cur n return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF min(a, b, c) > 0 min(a, b, c) min a b c 0 abs(a-A) + abs(b-B) + abs(c-C) - 30 abs(a-A) + abs(b-B) + abs(c-C) abs(a-A) + abs(b-B) abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C 30 INF ret0 = rec(cur+1, a, b, c) ret0 rec(cur+1, a, b, c) rec cur+1 cur 1 a b c ret1 = rec(cur+1, a+L[cur], b, c) + 10 ret1 rec(cur+1, a+L[cur], b, c) + 10 rec(cur+1, a+L[cur], b, c) rec cur+1 cur 1 a+L[cur] a L[cur] L cur b c 10 ret2 = rec(cur+1, a, b+L[cur], c) + 10 ret2 rec(cur+1, a, b+L[cur], c) + 10 rec(cur+1, a, b+L[cur], c) rec cur+1 cur 1 a b+L[cur] b L[cur] L cur c 10 ret3 = rec(cur+1, a, b, c+L[cur]) + 10 ret3 rec(cur+1, a, b, c+L[cur]) + 10 rec(cur+1, a, b, c+L[cur]) rec cur+1 cur 1 a b c+L[cur] c L[cur] L cur 10 return min(ret0, ret1, ret2, ret3) min(ret0, ret1, ret2, ret3) min ret0 ret1 ret2 ret3 cur cur a a b b c c print(rec(0, 0, 0, 0)) print rec(0, 0, 0, 0) rec 0 0 0 0 A, B, C = map(int, input().split()) map(int, input().split()) A def rec(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = rec(cur+1, a, b, c)
    ret1 = rec(cur+1, a+L[cur], b, c) + 10
    ret2 = rec(cur+1, a, b+L[cur], c) + 10
    ret3 = rec(cur+1, a, b, c+L[cur]) + 10
    return min(ret0, ret1, ret2, ret3) def rec(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = rec(cur+1, a, b, c)
    ret1 = rec(cur+1, a+L[cur], b, c) + 10
    ret2 = rec(cur+1, a, b+L[cur], c) + 10
    ret3 = rec(cur+1, a, b, c+L[cur]) + 10
    return min(ret0, ret1, ret2, ret3) rec n, A, B, C = map(int, input().split()) map(int, input().split()) n INF = 10**9 10**9 INF B, C = map(int, input().split()) map(int, input().split()) B L = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] L 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 rec(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = rec(cur+1, a, b, c)
    ret1 = rec(cur+1, a+L[cur], b, c) + 10
    ret2 = rec(cur+1, a, b+L[cur], c) + 10
    ret3 = rec(cur+1, a, b, c+L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(rec(0, 0, 0, 0))
