ii. the least of (1) if the taxpayer ceases to be resident in Canada immediately after the end of the year, the particular amount,
(2) if subparagraph 1 does not apply, 30% of the particular amount,
(3) the amount by which the taxpayer’s foreign resource income for the year in relation to that country exceeds the portion of the amount, deducted under section 371 in computing the taxpayer’s income for the year, that is attributable to a source in that country, and
(4) the amount by which the aggregate of all amounts each of which is the taxpayer’s foreign resource income for the year in relation to a country exceeds the total of the aggregate of all amounts each of which is the taxpayer’s foreign resource loss for the year in relation to a country and the amount deducted under section 371 in computing the taxpayer’s income for the year; and