It's a 2012 imac.
I suggest you boot to INTERNET Recovery (command+OPTION+R at boot), and try a reinstall of the OS that way.
If you are unsure as to how to make internet recovery work, let us know and we'll advise you.
You CANNOT use "ordinary" (i.e., non-internet) recovery to erase the internal drive.
You must use internet recovery or boot from an external drive or USB flash drive.
Also, when using internet recovery, once the internet utilities are loaded, you need to
- open disk utility
- VERY IMPORTANT: go to the view menu (if there is one) and choose "show all devices"
- the top line is the internal drive -- that's what needs to be erased.
- erase the drive and quit disk utility, then open the installer.
Everymac.com indicates the most recent OS for the 2012 imac is 10.15 "Catalina".
I suggest that you install that -- NOT High Sierra.
Good luck.
One more thing:
If you're going to sell this, install the new OS.
You should get to the point where you see the initial setup screen "choose your language".
I recommend that you quit the installer at that point.
If you can't find any way to quit it, just reach around back, and press AND HOLD the power on button until the screen goes dark and the imac shuts off.
It's ready for the next owner.