n,a,b,c = int(input().split())
mp = 0
la = 0
lb = 0
lc = 0
for i in range(n):
    l = int(input().split())
    if abs(l[i] - a) < la:
        la = l[i]
    if abs(l[i] - b) < lb:
        lb = l[i]
    if abs(l[i] - c) < lc:
        lc = l[i]
af=0
bf=0
cf=0
for i in range(n):
    for j in (i,n):
        if abs(l[i]+l[j]-a) < la:
            la - l[i]+l[j]
            if af == 0:
                mp = mp+10
        if abs(l[i]+l[j]-b) < lb:
            lb = l[i]+l[j]
            if bf == 0:
                mp = mp+10
        if abs(l[i]+l[j]-c) < lc:
            lc = l[i]+l[j]
            if cf == 0:
                mp = mp+10

while la != a:
    if la < a:
        la = la+1
        mp = mp+1
    else:
        if la > 2:
            la = la-1
            mp = mp+1
while lb != b:
    if lb < b:
        lb = lb+1
        mp = mp+1
    else:
        if lb > 2:
            lb = lb-1
            mp = mp+1
while lc != c:
    if lc < c:
        lc = lc+1
        mp = mp+1
    else:
        if lc > 2:
            lc = lc-1
            mp = mp+1
print(mp)
