# ABC119C - Synthetic Kadomatsu
def dfs() -> int:
    stack = [(0, 0, 0, 0, 0)]
    cand = set()
    while stack:
        cur, x, y, z, cnt = stack.pop()
        if cur == N:
            if min(x, y, z):
                cand.add(abs(x - A) + abs(y - B) + abs(z - C) + cnt - 30)
            continue
        stack.append((cur + 1, x, y, z, cnt + 10))
        stack.append((cur + 1, x + L[cur], y, z, cnt + 10))
        stack.append((cur + 1, x, y + L[cur], z, cnt + 10))
        stack.append((cur + 1, x, y, z + L[cur], cnt + 10))
    return min(cand)


def main():
    global N, A, B, C, L
    N, A, B, C, *L = map(int, open(0).read().split())
    ans = dfs()
    print(ans)


if __name__ == "__main__":
    main()