n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = float("INF")
for a in range(2**n):
    d0 = [(a >> b) & 1 for b in range(n)]
    for c in range(2**n):
        d1 = [(c >> d) & 1 for d in range(n)]
        abc = [0] * 3
        ans_ = 0
        for i in range(n):
            if d0[i] == 1 and d1[i] == 1:
                if abc[0]: ans_ += 10
                abc[0] += l[i]
            elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
            elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
        if abc[0] == 0 or abc[1] == 0 or abc[2] == 0: continue
        ans_ += abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C)
        ans = min(ans, ans_)
print(ans) n, A, B, C = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split 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 l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] ans = float("INF") ans float("INF") float "INF" for a in range(2**n):
    d0 = [(a >> b) & 1 for b in range(n)]
    for c in range(2**n):
        d1 = [(c >> d) & 1 for d in range(n)]
        abc = [0] * 3
        ans_ = 0
        for i in range(n):
            if d0[i] == 1 and d1[i] == 1:
                if abc[0]: ans_ += 10
                abc[0] += l[i]
            elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
            elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
        if abc[0] == 0 or abc[1] == 0 or abc[2] == 0: continue
        ans_ += abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C)
        ans = min(ans, ans_) a range(2**n) range 2**n 2 n (a >> b) & 1 for b in range(n) for b in range(n) b range(n) range n for b in range(n) (a >> b) & 1 a >> b a b 1 d0 = [(a >> b) & 1 for b in range(n)] d0 [(a >> b) & 1 for b in range(n)] for c in range(2**n):
        d1 = [(c >> d) & 1 for d in range(n)]
        abc = [0] * 3
        ans_ = 0
        for i in range(n):
            if d0[i] == 1 and d1[i] == 1:
                if abc[0]: ans_ += 10
                abc[0] += l[i]
            elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
            elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
        if abc[0] == 0 or abc[1] == 0 or abc[2] == 0: continue
        ans_ += abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C)
        ans = min(ans, ans_) c range(2**n) range 2**n 2 n (c >> d) & 1 for d in range(n) for d in range(n) d range(n) range n for d in range(n) (c >> d) & 1 c >> d c d 1 d1 = [(c >> d) & 1 for d in range(n)] d1 [(c >> d) & 1 for d in range(n)] abc = [0] * 3 abc [0] * 3 [0] 0 3 ans_ = 0 ans_ 0 for i in range(n):
            if d0[i] == 1 and d1[i] == 1:
                if abc[0]: ans_ += 10
                abc[0] += l[i]
            elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
            elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
         i range(n) range n if d0[i] == 1 and d1[i] == 1:
                if abc[0]: ans_ += 10
                abc[0] += l[i]
            elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
            elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
         d0[i] == 1 and d1[i] == 1 d0[i] == 1 d0[i] d0 i 1 d1[i] == 1 d1[i] d1 i 1 if abc[0]: ans_ += 10
                 abc[0] abc 0 abc[0] += l[i] abc[0] abc 0 l[i] l i elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
             d0[i] == 0 and d1[i] == 1 d0[i] == 0 d0[i] d0 i 0 d1[i] == 1 d1[i] d1 i 1 if abc[1]: ans_ += 10
                 abc[1] abc 1 abc[1] += l[i] abc[1] abc 1 l[i] l i elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
         d0[i] == 1 and d1[i] == 0 d0[i] == 1 d0[i] d0 i 1 d1[i] == 0 d1[i] d1 i 0 if abc[2]: ans_ += 10
                 abc[2] abc 2 abc[2] += l[i] abc[2] abc 2 l[i] l i if abc[0] == 0 or abc[1] == 0 or abc[2] == 0: continue
         abc[0] == 0 or abc[1] == 0 or abc[2] == 0 abc[0] == 0 or abc[1] == 0 abc[0] == 0 abc[0] abc 0 0 abc[1] == 0 abc[1] abc 1 0 abc[2] == 0 abc[2] abc 2 0 ans_ += abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C) ans_ abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C) abs(abc[0]-A)+abs(abc[1]-B) abs(abc[0]-A) abs abc[0]-A abc[0] abc 0 A abs(abc[1]-B) abs abc[1]-B abc[1] abc 1 B abs(abc[2]-C) abs abc[2]-C abc[2] abc 2 C ans = min(ans, ans_) ans min(ans, ans_) min ans ans_ print(ans) print ans ans = float("INF") float("INF") ans d0 = [(a >> b) & 1 for b in range(n)] [(a >> b) & 1 for b in range(n)] d0 C = map(int, input().split()) map(int, input().split()) C ans = min(ans, ans_) min(ans, ans_) ans l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l ans_ = 0 0 ans_ A, B, C = map(int, input().split()) map(int, input().split()) A B, C = map(int, input().split()) map(int, input().split()) B ans_ += abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C) abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C) ans_ d1 = [(c >> d) & 1 for d in range(n)] [(c >> d) & 1 for d in range(n)] d1 abc = [0] * 3 [0] * 3 abc n, A, B, C = map(int, input().split()) map(int, input().split()) n
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = float("INF")
for a in range(2**n):
    d0 = [(a >> b) & 1 for b in range(n)]
    for c in range(2**n):
        d1 = [(c >> d) & 1 for d in range(n)]
        abc = [0] * 3
        ans_ = 0
        for i in range(n):
            if d0[i] == 1 and d1[i] == 1:
                if abc[0]: ans_ += 10
                abc[0] += l[i]
            elif d0[i] == 0 and d1[i] == 1:
                if abc[1]: ans_ += 10
                abc[1] += l[i]
            elif d0[i] == 1 and d1[i] == 0:
                if abc[2]: ans_ += 10
                abc[2] += l[i]
        if abc[0] == 0 or abc[1] == 0 or abc[2] == 0: continue
        ans_ += abs(abc[0]-A)+abs(abc[1]-B)+abs(abc[2]-C)
        ans = min(ans, ans_)
print(ans)