I am assuming you are raising this question for tax reasons. Contact your tax advisor, but a simplified version would be something like this:
Sales proceeds minus closing costs at sale = Net proceeds
Original purchase price + closing costs at purchase + capital reserve portion (only) of dues = Adjusted basis
Net proceeds minus adjusted basis = Gain or loss