There are 4 slots. 2 slots taken by 2x4GB that came with Mac at purchase. Max memory is specified as 32GB. Can I buy 1x8GB and 1x16GB to fill the remaining 2 slots. Or do I need to use 8GB for both remaining slots. Thank you!
The general rule is you can mismatch sizes in pairs but not in individual slots.
Computers use interleaved memory, which requires each pair of slots to be populated with the exact same RAM. Having mis-matched slots will 'break' the interleaving & slow down the RAM access. As far as I'm aware this isn't 'dangerous' at all, merely slower.
Some machines can also use triple-channel memory, where three matching memory sticks can be interleaved. I don't know whether your iMac can do that, it may only be the Mac Pros that can - though in this case would make your issue harder to solve [I'm just including it for completeness]
So, your ideal way to achieve 32GB would be 4 x 8GB, which is probably cheaper than 2 x 16 anyway. If you keep the existing 4's I would add a pair of 8's.
Crucial's RAM configurator, on a quick search [check for your exact model] shows no 16GB sticks at all.