both of two are formal expression and polite way used in when you talk with older people or
meeting with someone first time. ( No one want to friendy speak in first time. I think it is rude manner)
but 잘 지내십니까? is more polite and likely used in official place.
and 잘 지내시나요? is also polite, but lf you want to make closed relationship with whom, 잘 지내요? is more recommended expression in korea I think.