#N/A in incomplete formula is ruining other cells

I have a spreadsheet to track which local trails I’ve hiked. The trails are all listed in a dropdown in column D. The trails are also all listed in column N, with corresponding mileages in column O. I’ve got the mileages appearing automatically in column B with the formula:

=INDEX(O:O,MATCH(D20,N:N),0)

This instance, of course, resides in cell B20.

My problem is that at the bottom of the spreadsheet I’m totaling the mileages to track how far I’ve walked, but the formula is showing #N/A when I do not have a trail selected in column D. Is there a way for me to show a blank cell in column B until something is selected from the dropdown?