Sex is the key to staying sharp in old age, says study