RO system with energy recovery