You can upgrade only to what Apple offered for this iMac, so an i7-7700K CPU (K is important). No i9 or different i7.
open