This paper develops a general theory of aggregation in inefficient economies. We provide non-parametric formulas for aggregating microeconomic shocks in economies with distortions such as taxes, markups, frictions to resource reallocation, financial frictions, and nominal rigidities. We allow for arbitrary elasticities of substitution, returns to scale, factor mobility, and input-output network linkages. We show how to separately measure changes in technical and allocative efficiency. We also show how to compute the social cost of distortions. We pursue applications focusing on firm-level markups in the U.S. We find that improvement in allocative efficiency, due to the reallocation over time of market share to high-markup firms, accounts for about half of aggregate TFP growth over the period 1997-2015. We also find that eliminating the misallocation resulting from the large and dispersed markups estimated in the data would raise aggregate TFP by about 20%, increasing the economy-wide cost of monopoly distortions by two orders of magnitude compared to the famous 0.1% estimate by Harberger (1954). These exact numbers should be interpreted with care since the data is imperfect and requires substantial imputation.