N, A, B, C = map(int, input().split())
L = [0]*N
for i in range(N):
    L[i] = int(input())
INF = 10 ** 9


def dfs(times, a, b, c):  
    if times == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    no_pattern = dfs(times + 1, a, b, c)
    a_pattern = dfs(times + 1, a + L[times], b, c) + 10
    b_pattern = dfs(times + 1, a, b + L[times], c) + 10
    c_pattern = dfs(times + 1, a, b, c + L[times]) + 10

    return min(no_pattern, a_pattern, b_pattern, c_pattern)


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 L = [0]*N L [0]*N [0] 0 N for i in range(N):
    L[i] = int(input()) i range(N) range N L[i] = int(input()) L[i] L i int(input()) int input() input INF = 10 ** 9 INF 10 ** 9 10 9 def dfs(times, a, b, c):  
    if times == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    no_pattern = dfs(times + 1, a, b, c)
    a_pattern = dfs(times + 1, a + L[times], b, c) + 10
    b_pattern = dfs(times + 1, a, b + L[times], c) + 10
    c_pattern = dfs(times + 1, a, b, c + L[times]) + 10

    return min(no_pattern, a_pattern, b_pattern, c_pattern) dfs if times == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
     times == N times 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 no_pattern = dfs(times + 1, a, b, c) no_pattern dfs(times + 1, a, b, c) dfs times + 1 times 1 a b c a_pattern = dfs(times + 1, a + L[times], b, c) + 10 a_pattern dfs(times + 1, a + L[times], b, c) + 10 dfs(times + 1, a + L[times], b, c) dfs times + 1 times 1 a + L[times] a L[times] L times b c 10 b_pattern = dfs(times + 1, a, b + L[times], c) + 10 b_pattern dfs(times + 1, a, b + L[times], c) + 10 dfs(times + 1, a, b + L[times], c) dfs times + 1 times 1 a b + L[times] b L[times] L times c 10 c_pattern = dfs(times + 1, a, b, c + L[times]) + 10 c_pattern dfs(times + 1, a, b, c + L[times]) + 10 dfs(times + 1, a, b, c + L[times]) dfs times + 1 times 1 a b c + L[times] c L[times] L times 10 return min(no_pattern, a_pattern, b_pattern, c_pattern) min(no_pattern, a_pattern, b_pattern, c_pattern) min no_pattern a_pattern b_pattern c_pattern times times a a b b c c print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 B, C = map(int, input().split()) map(int, input().split()) B A, B, C = map(int, input().split()) map(int, input().split()) A INF = 10 ** 9 10 ** 9 INF N, A, B, C = map(int, input().split()) map(int, input().split()) N L = [0]*N [0]*N L def dfs(times, a, b, c):  
    if times == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    no_pattern = dfs(times + 1, a, b, c)
    a_pattern = dfs(times + 1, a + L[times], b, c) + 10
    b_pattern = dfs(times + 1, a, b + L[times], c) + 10
    c_pattern = dfs(times + 1, a, b, c + L[times]) + 10

    return min(no_pattern, a_pattern, b_pattern, c_pattern) def dfs(times, a, b, c):  
    if times == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    no_pattern = dfs(times + 1, a, b, c)
    a_pattern = dfs(times + 1, a + L[times], b, c) + 10
    b_pattern = dfs(times + 1, a, b + L[times], c) + 10
    c_pattern = dfs(times + 1, a, b, c + L[times]) + 10

    return min(no_pattern, a_pattern, b_pattern, c_pattern) dfs C = map(int, input().split()) map(int, input().split()) C
N, A, B, C = map(int, input().split())
L = [0]*N
for i in range(N):
    L[i] = int(input())
INF = 10 ** 9


def dfs(times, a, b, c):  
    if times == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    no_pattern = dfs(times + 1, a, b, c)
    a_pattern = dfs(times + 1, a + L[times], b, c) + 10
    b_pattern = dfs(times + 1, a, b + L[times], c) + 10
    c_pattern = dfs(times + 1, a, b, c + L[times]) + 10

    return min(no_pattern, a_pattern, b_pattern, c_pattern)


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