Installing RAM - 27 inch late 2013 iMac
I'd suggest you look at your RAM usage in Activity Monitor first. 16 Gb is plenty for most tasks. If you're seeing low memory pressure (Green on the graph), then you might be better off with the SSD first.

Here's an example of very low RAM usage: tiny amount of Green; no Swap, no Compressed memory. If you've been running for a long time, you can expect some swap.



Here's a similar setup using 8Gb of RAM, which is coping, but could benefit from more RAM:



Pressure is still green, but higher. It's not Yellow or Red, though; but it's having to compress some memory to cope.

Don't forget that MacOS tries to use as much memory as possible, so simply using lots of RAM is not an indicator that you need more.

An SSD will be a much more noticeable improvement, with app launches, document loading and other disk-related activities all being orders of magnitude faster.