Rent demand from Owner

Dear Sir I have entered into an agreement with My owner on April 1st 2016 for 11 Months. I have paid two months of rent AS ADVANCE. As per agreement I have to pay Rent + Maintenance to my owner. On May 27 I received Complaint from Maintenance office that Maintenance bills are not being paid for my flat an dthey disconnected the power. I paid Rs 5000 to restore the connection. Now my Owner has Rs 21000 in advance from me. On June 1 he informed us that the flat is being sold and but I may continue until further notice. As my owner has two months advance Rent + Maintenance I did not pay Rent for June( It was informed by My owner itself to not to pay the rent as Advance is lying with him) But on July 3rd he is asking me to pay the rent or Pay Monthly rent even when I told him that Iam vacating on July 31st. He is insisting me to vacate flat on 15th if I don't pay the rent/advance. Should I pay him rent /advance even if iam vacating on 31st July ( My owner already have the rent in the name of advance) I have paid maintenance amount instead of owner for two months. Please guide me.