Sounds like you need serious professional help. Your second mortgage probably will not be discharged by the foreclosure. Most of my clients is similar situations choose the short sale route. Your credit will be dinged but our attorneys will make sure all liens are released. Call me to discuss.
As a rule, the 1st Lienholder will have to take care of the other Liens.
This is too important, for you not to take it to an Attorney;
particularly since N.Y. is a RECOURSE State.
Good luck and may God bless