n,a,b,c=[int(i) for i in input().split()]
goal=[a,b,c]
l=[]
for i in range(n):
    l.append(int(input()))
point=0
for j in range(len(l)):
    try:
        for i in range(9):
            if (l[j]+i) in goal:
                goal.remove(l[j]+i)
                l.remove(l[j])
                point+=i
            elif (l[j]-i) in goal:
                goal.remove(l[j]-i)
                l.remove(l[j])
                point+=i
    except:
        pass
print(point)