Maximal superintegrability on N-dimensional curved spaces