The 27" iMac has four RAM slots, two are taken by two 2 GB (not MB or Mb) RAM modules, leaving room for two additional RAM modules, thus you can add two 4 GB modules to get 12 GB. The 27" iMac can either handle 16 or 32 GB RAM as maximum.
No matter, many have done the same before replacing the old 2 GB modules with another pair of 4 GB modules, once 12 GB was not enough.
If you have a 2010 or 2011 iMac, you can use four 8 GB modules to get to 32 GB, for around 200 USD or less, if you need to.