Ab initio calculation of the neutron-proton mass difference