### BUGGY CODE ###

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def calc(L, nowA, nowB, nowC, nowD, i, j):
    if i == 0:
        nowD += L[j]
    elif i == 1:
        nowA += L[j]
    elif i == 2:
        nowB += L[j]
    elif i == 3:
        nowC += L[j]

    return nowA, nowB, nowC, nowD

def num(i1, i2, i3, i4, i5, i6, i7, i8, t):
    return (i1 == t) + (i2 == t) + (i3 == t) + (i4 == t) + (i5 == t) + (i6 == t) + (i7 == t) + (i8 == t)

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2]), int(input_raw[3])]
    L = []
    for i in range(N):
        input_raw = read_func().strip().split()
        L.append(int(input_raw[0]))
    min_MP = sys.maxint
    for i1 in range(0, 4 if N >= 1 else 1):
        for i2 in range(0, 4 if N >= 2 else 1):
            for i3 in range(0, 4 if N >= 3 else 1):
                for i4 in range(0, 4 if N >= 4 else 1):
                    for i5 in range(0, 4 if N >= 5 else 1):
                        for i6 in range(0, 4 if N >= 6 else 1):
                            for i7 in range(0, 4 if N >= 7 else 1):
                                for i8 in range(0, 4 if N >= 8 else 1):
                                    nowA = 0
                                    nowB = 0
                                    nowC = 0
                                    nowD = 0
                                    if N >= 1:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i1, 0)
                                    if N >= 2:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i2, 1)
                                    if N >= 3:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i3, 2)
                                    if N >= 4:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i4, 3)
                                    if N >= 5:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i5, 4)
                                    if N >= 6:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i6, 5)
                                    if N >= 7:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i7, 6)
                                    if N >= 8:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i8, 7)

                                    Anum = num(i1,i2,i3,i4,i5,i6,i7,i8,1)
                                    Bnum = num(i1,i2,i3,i4,i5,i6,i7,i8,2)
                                    Cnum = num(i1,i2,i3,i4,i5,i6,i7,i8,3)
                                    if Anum <= 0 or Bnum <= 0 or Cnum <= 0:
                                        continue
                                    MP = (Anum -1) * 10 + abs(nowA - A)
                                    MP += (Bnum - 1) * 10 + abs(nowB - B)
                                    MP += (Cnum - 1) * 10 + abs(nowC - C)
                                    min_MP = min(MP, min_MP)
    print min_MP
##    min_MP = sys.maxint
##    for i in range(N):
##        for j in range(i, N):
##            for k in range(j, N):
##                MP = 0
##                forA = sum(L[i:j])
##                if (j - i) > 1:
##                    MP += 10 * (j - i - 1)
##                MP += abs(A-forA)
##                forB = sum(L[j:k])
##                if (k - j) > 1:
##                    MP += 10 * (k - j - 1)
##                MP += abs(B-forB)
##                forC = sum(L[k:N])
##                if (N - k) > 1:
##                    MP += 10 * (N - k - 1)
##                MP += abs(C-forC)
##                min_MP = min(min_MP, MP)




if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def calc(L, nowA, nowB, nowC, nowD, i, j):
    if i == 0:
        nowD += L[j]
    elif i == 1:
        nowA += L[j]
    elif i == 2:
        nowB += L[j]
    elif i == 3:
        nowC += L[j]

    return nowA, nowB, nowC, nowD

def num(i1, i2, i3, i4, i5, i6, i7, i8, t):
    return (i1 == t) + (i2 == t) + (i3 == t) + (i4 == t) + (i5 == t) + (i6 == t) + (i7 == t) + (i8 == t)

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2]), int(input_raw[3])]
    L = []
    for i in range(N):
        input_raw = read_func().strip().split()
        L.append(int(input_raw[0]))
    min_MP = sys.maxint
    for i1 in range(0, 4 if N >= 1 else 1):
        for i2 in range(0, 4 if N >= 2 else 1):
            for i3 in range(0, 4 if N >= 3 else 1):
                for i4 in range(0, 4 if N >= 4 else 1):
                    for i5 in range(0, 4 if N >= 5 else 1):
                        for i6 in range(0, 4 if N >= 6 else 1):
                            for i7 in range(0, 4 if N >= 7 else 1):
                                for i8 in range(0, 4 if N >= 8 else 1):
                                    nowA = 0
                                    nowB = 0
                                    nowC = 0
                                    nowD = 0
                                    if N >= 1:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i1, 0)
                                    if N >= 2:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i2, 1)
                                    if N >= 3:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i3, 2)
                                    if N >= 4:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i4, 3)
                                    if N >= 5:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i5, 4)
                                    if N >= 6:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i6, 5)
                                    if N >= 7:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i7, 6)
                                    if N >= 8:
                                        nowA,nowB,nowC,nowD = calc(L, nowA,nowB,nowC,nowD, i8, 7)

                                    Anum = num(i1,i2,i3,i4,i5,i6,i7,i8,1)
                                    Bnum = num(i1,i2,i3,i4,i5,i6,i7,i8,2)
                                    Cnum = num(i1,i2,i3,i4,i5,i6,i7,i8,3)
                                    if Anum <= 0 or Bnum <= 0 or Cnum <= 0:
                                        continue
                                    MP = (Anum -1) * 10 + abs(nowA - A)
                                    MP += (Bnum - 1) * 10 + abs(nowB - B)
                                    MP += (Cnum - 1) * 10 + abs(nowC - C)
                                    min_MP = min(MP, min_MP)
    print min_MP
##    min_MP = sys.maxint
##    for i in range(N):
##        for j in range(i, N):
##            for k in range(j, N):
##                MP = 0
##                forA = sum(L[i:j])
##                if (j - i) > 1:
##                    MP += 10 * (j - i - 1)
##                MP += abs(A-forA)
##                forB = sum(L[j:k])
##                if (k - j) > 1:
##                    MP += 10 * (k - j - 1)
##                MP += abs(B-forB)
##                forC = sum(L[k:N])
##                if (N - k) > 1:
##                    MP += 10 * (N - k - 1)
##                MP += abs(C-forC)
##                min_MP = min(min_MP, MP)




if __name__ == '__main__':
    main()