Brazil is the largest country in both South America and Latin America by area and population. It has a coastline of over 7,000 km bordering the Atlantic Ocean, and is bounded by every South American country except Ecuador and Chile. Portugal colonized Brazil in 1500 and it remained a Portuguese colony until 1808, when the Portuguese royal family and capital city fled to Rio de Janeiro after Napoleon's invasion of Portugal.