Brazil survived Gabriel Jesus' second-half red card to end their 12-year wait for a trophy with a 3-1 victory over Peru in the Copa America final.