def li():
    return [int(x) for x in input().split()]
INF = 10**18
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, A, B, C = li()
l = [int(input()) for x in range(N)]

def dfs(index, a, b, c, none):
    # 終端
    if index == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
    v1 = dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0)
    v2 = dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0)
    v3 = dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0)
    v4 = dfs(index+1, a, b, c, none+1)
    return min(v1, v2, v3, v4)

ans = dfs(0, 0, 0, 0, 0)
print(ans) def li():
    return [int(x) for x in input().split()] li int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x return [int(x) for x in input().split()] [int(x) for x in input().split()] INF = 10**18 INF 10**18 10 18 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 N, A, B, C = li() N li() li A B C int(input()) for x in range(N) for x in range(N) x range(N) range N for x in range(N) int(input()) int input() input l = [int(input()) for x in range(N)] l [int(input()) for x in range(N)] def dfs(index, a, b, c, none):
    # 終端
    if index == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
    v1 = dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0)
    v2 = dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0)
    v3 = dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0)
    v4 = dfs(index+1, a, b, c, none+1)
    return min(v1, v2, v3, v4) dfs if index == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
     index == N index N if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
     min(a, b, c) > 0 min(a, b, c) min a b c 0 return abs(a - A) + abs(b - B) + abs(c - C) 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 return INF INF v1 = dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0) v1 dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0) dfs(index+1, a + l[index], b, c, none) dfs index+1 index 1 a + l[index] a l[index] l index b c none 10 if a > 0 else 0 a > 0 a 0 10 0 v2 = dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0) v2 dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0) dfs(index+1, a, b + l[index], c, none) dfs index+1 index 1 a b + l[index] b l[index] l index c none 10 if b > 0 else 0 b > 0 b 0 10 0 v3 = dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0) v3 dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0) dfs(index+1, a, b, c + l[index], none) dfs index+1 index 1 a b c + l[index] c l[index] l index none 10 if c > 0 else 0 c > 0 c 0 10 0 v4 = dfs(index+1, a, b, c, none+1) v4 dfs(index+1, a, b, c, none+1) dfs index+1 index 1 a b c none+1 none 1 return min(v1, v2, v3, v4) min(v1, v2, v3, v4) min v1 v2 v3 v4 index index a a b b c c none none ans = dfs(0, 0, 0, 0, 0) ans dfs(0, 0, 0, 0, 0) dfs 0 0 0 0 0 print(ans) print ans N, A, B, C = li() li() N l = [int(input()) for x in range(N)] [int(input()) for x in range(N)] l ans = dfs(0, 0, 0, 0, 0) dfs(0, 0, 0, 0, 0) ans A, B, C = li() li() A def li():
    return [int(x) for x in input().split()] def li():
    return [int(x) for x in input().split()] li def dfs(index, a, b, c, none):
    # 終端
    if index == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
    v1 = dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0)
    v2 = dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0)
    v3 = dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0)
    v4 = dfs(index+1, a, b, c, none+1)
    return min(v1, v2, v3, v4) def dfs(index, a, b, c, none):
    # 終端
    if index == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
    v1 = dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0)
    v2 = dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0)
    v3 = dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0)
    v4 = dfs(index+1, a, b, c, none+1)
    return min(v1, v2, v3, v4) dfs INF = 10**18 10**18 INF input = sys.stdin.readline sys.stdin.readline input B, C = li() li() B C = li() li() C
def li():
    return [int(x) for x in input().split()]
INF = 10**18
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, A, B, C = li()
l = [int(input()) for x in range(N)]

def dfs(index, a, b, c, none):
    # 終端
    if index == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
    v1 = dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0)
    v2 = dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0)
    v3 = dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0)
    v4 = dfs(index+1, a, b, c, none+1)
    return min(v1, v2, v3, v4)

ans = dfs(0, 0, 0, 0, 0)
print(ans)