N,A,B,C = map(int,input().split(" "))
L = []
for i in range(N):
    L.append(int(input()))
#print(L)
D = [A,B,C]
L = sorted(L)
MP = 0
flag = []
for i in range(3):
    for j in range(N-len(flag)):
        if D[i] == L[j]:
            MP += 0
            L.remove(D[i])
            flag.append(i)
            break
        else:
            pass
#print(flag)
if len(flag) == 3:
    print(0)
else:
    for i in range(len(flag)):
        D.remove(D[flag[i]])
    #print(D)
    #print(L)

    for i in range(len(D)):
        DIF = []
        for j in range(len(L)):
            DIF.append(abs(D[i] - L[j]))
        #print(DIF)
        #print(min(DIF))
        if min(DIF) <= 10:
            MP += min(DIF)
    print(MP)