import sys
from itertools import product
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, A, B, C = map(int, input().split())
    goal = [A, B, C]
    L = list(int(input()) for _ in range(n))

    res = f_inf
    for pattern in product([0, 1, 2, 3], repeat=n):
        cnt = [0] * 3
        length = [0] * 3
        for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
        mp = 0
        for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
    print(res)


if __name__ == '__main__':
    resolve() import sys sys from itertools import product sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    n, A, B, C = map(int, input().split())
    goal = [A, B, C]
    L = list(int(input()) for _ in range(n))

    res = f_inf
    for pattern in product([0, 1, 2, 3], repeat=n):
        cnt = [0] * 3
        length = [0] * 3
        for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
        mp = 0
        for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
    print(res) resolve n, A, B, C = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split A B C goal = [A, B, C] goal [A, B, C] A B C L = list(int(input()) for _ in range(n)) L list(int(input()) for _ in range(n)) list int(input()) int input() input res = f_inf res f_inf for pattern in product([0, 1, 2, 3], repeat=n):
        cnt = [0] * 3
        length = [0] * 3
        for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
        mp = 0
        for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
     pattern product([0, 1, 2, 3], repeat=n) product [0, 1, 2, 3] 0 1 2 3 repeat=n repeat n cnt = [0] * 3 cnt [0] * 3 [0] 0 3 length = [0] * 3 length [0] * 3 [0] 0 3 for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
         idx p enumerate(pattern) enumerate pattern if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
         p != 0 p 0 length[p - 1] += L[idx] length[p - 1] length p - 1 p 1 L[idx] L idx cnt[p - 1] += 1 cnt[p - 1] cnt p - 1 p 1 1 mp = 0 mp 0 for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
     i range(3) range 3 if cnt[i] == 0:
                break
             cnt[i] == 0 cnt[i] cnt i 0 break mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10 mp abs(goal[i] - length[i]) + (cnt[i] - 1) * 10 abs(goal[i] - length[i]) abs goal[i] - length[i] goal[i] goal i length[i] length i (cnt[i] - 1) * 10 cnt[i] - 1 cnt[i] cnt i 1 10 res = min(res, mp) res min(res, mp) min res mp print(res) print res if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve mod = 10 ** 9 + 7 10 ** 9 + 7 mod input = sys.stdin.readline sys.stdin.readline input def resolve():
    n, A, B, C = map(int, input().split())
    goal = [A, B, C]
    L = list(int(input()) for _ in range(n))

    res = f_inf
    for pattern in product([0, 1, 2, 3], repeat=n):
        cnt = [0] * 3
        length = [0] * 3
        for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
        mp = 0
        for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
    print(res) def resolve():
    n, A, B, C = map(int, input().split())
    goal = [A, B, C]
    L = list(int(input()) for _ in range(n))

    res = f_inf
    for pattern in product([0, 1, 2, 3], repeat=n):
        cnt = [0] * 3
        length = [0] * 3
        for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
        mp = 0
        for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
    print(res) resolve f_inf = float('inf') float('inf') f_inf
import sys
from itertools import product
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, A, B, C = map(int, input().split())
    goal = [A, B, C]
    L = list(int(input()) for _ in range(n))

    res = f_inf
    for pattern in product([0, 1, 2, 3], repeat=n):
        cnt = [0] * 3
        length = [0] * 3
        for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
        mp = 0
        for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
    print(res)


if __name__ == '__main__':
    resolve()
