US supermarket firm Great Atlantic & Pacific Tea Company (A&P) has reported a second-quarter profit, boosted by a gain on the sale of A&P Canada.