import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
INF = 10**9

def main():
    N, A, B, C = input_nums()
    ll = [int(input()) for _ in range(N)]

    def dfs(idx, a, b, c):
        if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = dfs(idx+1, a, b, c)
        ret1 = dfs(idx+1, a+ll[idx], b, c) + 10
        ret2 = dfs(idx+1, a, b+ll[idx], c) + 10
        ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10
        return min(ret0, ret1, ret2, ret3)

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


if __name__ == '__main__':
    main() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip input_nums = lambda: list(map(int, input().split())) input_nums lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF = 10**9 INF 10**9 10 9 def main():
    N, A, B, C = input_nums()
    ll = [int(input()) for _ in range(N)]

    def dfs(idx, a, b, c):
        if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = dfs(idx+1, a, b, c)
        ret1 = dfs(idx+1, a+ll[idx], b, c) + 10
        ret2 = dfs(idx+1, a, b+ll[idx], c) + 10
        ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10
        return min(ret0, ret1, ret2, ret3)

    print(dfs(0,0,0,0)) main N, A, B, C = input_nums() N input_nums() input_nums 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 ll = [int(input()) for _ in range(N)] ll [int(input()) for _ in range(N)] def dfs(idx, a, b, c):
        if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = dfs(idx+1, a, b, c)
        ret1 = dfs(idx+1, a+ll[idx], b, c) + 10
        ret2 = dfs(idx+1, a, b+ll[idx], c) + 10
        ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10
        return min(ret0, ret1, ret2, ret3)

     dfs if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
         idx == N idx 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 ret0 = dfs(idx+1, a, b, c) ret0 dfs(idx+1, a, b, c) dfs idx+1 idx 1 a b c ret1 = dfs(idx+1, a+ll[idx], b, c) + 10 ret1 dfs(idx+1, a+ll[idx], b, c) + 10 dfs(idx+1, a+ll[idx], b, c) dfs idx+1 idx 1 a+ll[idx] a ll[idx] ll idx b c 10 ret2 = dfs(idx+1, a, b+ll[idx], c) + 10 ret2 dfs(idx+1, a, b+ll[idx], c) + 10 dfs(idx+1, a, b+ll[idx], c) dfs idx+1 idx 1 a b+ll[idx] b ll[idx] ll idx c 10 ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10 ret3 dfs(idx+1, a, b, c+ll[idx]) + 10 dfs(idx+1, a, b, c+ll[idx]) dfs idx+1 idx 1 a b c+ll[idx] c ll[idx] ll idx 10 return min(ret0, ret1, ret2, ret3) min(ret0, ret1, ret2, ret3) min ret0 ret1 ret2 ret3 idx idx a a b b c c print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, A, B, C = input_nums()
    ll = [int(input()) for _ in range(N)]

    def dfs(idx, a, b, c):
        if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = dfs(idx+1, a, b, c)
        ret1 = dfs(idx+1, a+ll[idx], b, c) + 10
        ret2 = dfs(idx+1, a, b+ll[idx], c) + 10
        ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10
        return min(ret0, ret1, ret2, ret3)

    print(dfs(0,0,0,0)) def main():
    N, A, B, C = input_nums()
    ll = [int(input()) for _ in range(N)]

    def dfs(idx, a, b, c):
        if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = dfs(idx+1, a, b, c)
        ret1 = dfs(idx+1, a+ll[idx], b, c) + 10
        ret2 = dfs(idx+1, a, b+ll[idx], c) + 10
        ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10
        return min(ret0, ret1, ret2, ret3)

    print(dfs(0,0,0,0)) main input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input INF = 10**9 10**9 INF input_nums = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) input_nums
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
INF = 10**9

def main():
    N, A, B, C = input_nums()
    ll = [int(input()) for _ in range(N)]

    def dfs(idx, a, b, c):
        if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = dfs(idx+1, a, b, c)
        ret1 = dfs(idx+1, a+ll[idx], b, c) + 10
        ret2 = dfs(idx+1, a, b+ll[idx], c) + 10
        ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10
        return min(ret0, ret1, ret2, ret3)

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


if __name__ == '__main__':
    main()