#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 119：C - Synthetic Kadomatsu


N, A, B, C = [int(i) for i in raw_input().strip().split(' ')]


def bitcount(n):
    nb = bin(n)[2:]
    return nb.count('1')


def suml(l, n):
    s = 0
    for i in range(N):
        s += l[i] * (n&1)
        n >>= 1
    return s


def main():

    l = []
    for _ in range(N):
        h = int(raw_input().strip())
        l.append(h)
    # l.sort(reverse=False)

    cand = []
    for i in range(2**N):
        cand.append((i, suml(l, i), bitcount(i)))
    # print cand

    '''
    # C
    mincmp = 10000000000000
    mincn = 0
    for c in cand:
        if c[2] <= N-2:
            mp = abs(C-c[1]) + 10*(c[2]-1)
            if mp < mincmp:
                mincmp = mp
                mincn = c[0]

    # B
    minbmp = 10000000000000
    minbn = 0
    for c in cand:
        if c[2] <= N-1 and c[0]&mincn==0:
            mp = abs(B-c[1]) + 10*(c[2]-1)
            if mp < minbmp:
                minbmp = mp
                minbn = c[0]
                print c, mp

    # A
    minamp = 10000000000000
    minan = 0
    for c in cand:
        if c[2] <= N and c[0]&(mincn|minbn)==0:
            mp = abs(A-c[1]) + 10*(c[2]-1)
            if mp < minamp:
                minamp = mp
                minan = c[0]
                print c, mp
    '''

    minmp = 10000000000000
    for a in range(1, N**2):
        if cand[a][2] <= N-2:
            for b in range(1, N**2):
                if cand[b][2] <= N-1 and cand[a][0]&cand[b][0]==0:
                    for c in range(1, N**2):
                        if cand[c][2] <= N and cand[c][0]&(cand[a][0]|cand[b][0]) == 0:
                            mp = abs(A-cand[a][1]) + 10*(cand[a][2]-1) + abs(B-cand[b][1]) + 10*(cand[b][2]-1) + abs(C-cand[c][1]) + 10*(cand[c][2]-1)
                            if mp < minmp:
                                minmp = mp
                                # print a, b, c
    print minmp


if __name__ == '__main__':
    main()
