Determination of the sources and sinks of N+ ions in the thermosphere