In economics, gains from trade are the net benefits to economic agents from being allowed an increase in voluntary trading with each other. In technical terms, they are the increase of consumer surplus plus producer surplus from lower tariffs or otherwise liberalizing trade. Gains from trade are commonly described as resulting from: specialization in production from division of labor, economies of scale, scope, and agglomeration and relative availability of factor resources in types of output by farms, businesses, location and economies a resulting increase in total output possibilities trade through markets from sale of one type of output for other, more highly valued goods. Market incentives, such as reflected in prices of outputs and inputs, are theorized to attract factors of production, including labor, into activities according to comparative advantage, that is, for which they each have a low opportunity cost. The factor owners then use their increased income from such specialization to buy more-valued goods of which they would otherwise be high-cost producers, hence their gains from trade. The concept may be applied to an entire economy for the alternatives of autarky (no trade) or trade. A measure of total gains from trade is the sum of consumer surplus and producer profits or, more roughly, the increased output from specialization in production with resulting trade. Gains from trade may also refer to net benefits to a country from lowering barriers to trade such as tariffs on imports. David Ricardo in 1817 first clearly stated and proved the principle of comparative advantage, termed a "fundamental analytical explanation" for the source of gains from trade. But from publication of Adam Smith's The Wealth of Nations in 1776, it was widely argued, that, with competition and absent market distortions, such gains are positive in moving toward free trade and away from autarky or prohibitively high import tariffs. Rigorous early contemporary statements of the conditions under which this proposition holds are found in Samuelson in 1939 and 1962.