from itertools import permutations, combinations


def solve(string):
    n, a, b, c, *l = map(int, string.split())
    ans = 3000
    for _l in permutations(l):
        for i, j, k in combinations(range(1, len(l) + 1), 3):
            tmp = 10 * (i - 1) + abs(a - sum(_l[:i]))
            if tmp > ans:
                continue
            tmp += 10 * (j - i - 1) + abs(b - sum(_l[i:j]))
            if tmp > ans:
                continue
            tmp += 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
            if tmp < ans:
                ans = tmp
    return str(ans)


if __name__ == '__main__':
    n, a, b, c = map(int, input().split())
    print(solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([input() for _ in range(n)])))
