-- Fredy Bareiro scored in the 71st minute Wednesday night as Paraguay upset Brazil, 2-1, to win Group C in the Copa America soccer tournament.

Paraguay finished atop the group with seven points in three matches, setting up a quarterfinal game against Uruguay on Sunday. Brazil, which was second with six points, will face Mexico in the quarterfinals of the South American tournament.

Costa Rica, which eliminated Chile, 2-1, on an injury-time goal earlier Wednesday, advanced as the second-best third-place team and will play Colombia this weekend.

The other quarterfinal match features Peru against Argentina.

Bareiro scored from inside the penalty area when he beat defender Luisao and sent a low shot past Brazil goalkeeper Julio Cesar.

Julio Gonzalez had put Paraguay ahead with a header off a corner kick in the 29th minute. Luis Fabiano got Brazil's equalizer with a hard right-footed shot from inside the area in the 35th minute.

Costa Rica beat Chile on Andy Herron's goal three minutes into second-half injury time. Herron's goal eliminated Chile and Bolivia, which would have qualified if the score remained 1-1.

Chile captain Rafael Olarra put his team ahead in the 40th minute when he was in the right place at the right time. Luis Jimenez's free kick glanced off the back of Costa Rica defender Cristian Badilla and in off the right shoulder of Olarra.

Costa Rica tied it just before the hour mark. Alonso Solis sent in a free kick that rebounded to Walter Centeno, whose shot from the right wing was trapped in the goal mouth by teammate Mauricio Wright, who tapped in the ball.

Herron then scored the winner with a hard shot from the right side past Chile goalkeeper Alex Varas.