N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
def rec(itr, a, b, c, mp):
    if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10 ** 9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
    res = rec(itr + 1, a, b, c, mp)
    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)
    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)
    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)
    return res
print(rec(0, 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)] def rec(itr, a, b, c, mp):
    if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10 ** 9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
    res = rec(itr + 1, a, b, c, mp)
    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)
    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)
    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)
    return res rec if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10 ** 9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
     itr == N itr N if a == 0 or b == 0 or c == 0:
            return 10 ** 9
         a == 0 or b == 0 or c == 0 a == 0 or b == 0 a == 0 a 0 b == 0 b 0 c == 0 c 0 return 10 ** 9 10 ** 9 10 9 return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30 abs(a - A) + abs(b - B) + abs(c - C) + mp - 30 abs(a - A) + abs(b - B) + abs(c - C) + mp 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 mp 30 res = rec(itr + 1, a, b, c, mp) res rec(itr + 1, a, b, c, mp) rec itr + 1 itr 1 a b c mp res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10) res min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10) min res rec(itr + 1, a + L[itr], b, c, mp) + 10 rec(itr + 1, a + L[itr], b, c, mp) rec itr + 1 itr 1 a + L[itr] a L[itr] L itr b c mp 10 res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10) res min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10) min res rec(itr + 1, a, b + L[itr], c, mp) + 10 rec(itr + 1, a, b + L[itr], c, mp) rec itr + 1 itr 1 a b + L[itr] b L[itr] L itr c mp 10 res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10) res min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10) min res rec(itr + 1, a, b, c + L[itr], mp) + 10 rec(itr + 1, a, b, c + L[itr], mp) rec itr + 1 itr 1 a b c + L[itr] c L[itr] L itr mp 10 return res res itr itr a a b b c c mp mp print(rec(0, 0, 0, 0, 0)) print rec(0, 0, 0, 0, 0) rec 0 0 0 0 0 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 def rec(itr, a, b, c, mp):
    if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10 ** 9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
    res = rec(itr + 1, a, b, c, mp)
    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)
    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)
    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)
    return res def rec(itr, a, b, c, mp):
    if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10 ** 9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
    res = rec(itr + 1, a, b, c, mp)
    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)
    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)
    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)
    return res rec 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
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
def rec(itr, a, b, c, mp):
    if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10 ** 9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
    res = rec(itr + 1, a, b, c, mp)
    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)
    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)
    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)
    return res
print(rec(0, 0, 0, 0, 0))
