A farmer bought 3 cows for $3000 and sold them for $3500. He bought them back for $4000 and sold again for $3600. How much did he gain or lose on these transactions?