# Deriving aggregate output from labor demand and supply

I was reading the following paper:

http://eml.berkeley.edu//~moretti/growth.pdf

I got stuck at equation (7)

The firm's production function is $$Y_{i}=A_{i}L_{i}^{\alpha}K_{i}^{\eta}T_{i}^{1-\alpha-\eta}$$

Labor supply is $$W_{i}=V\frac{P_{i}^{\beta}}{Z_{i}}=V\frac{\bar{P_{i}}^{\beta}L_{i}^{\beta \gamma_{i}}}{Z_{i}}$$

Labor demand is $$L_{i}=(\frac{\alpha^{1-\eta}\eta^{\eta}}{R^{\eta}}\frac{A_{i}}{W_{i}^{1-\eta}})^{\frac{1}{1-\alpha-\eta}}T_{i}$$

The paper says that if we impose aggregate labor demand is equal to aggregate labor supply (normalized to one), then the aggregate output $$Y=\sum_{i}Y_{i}$$ is

$$Y=(\frac{\eta}{R})^{\frac{\eta}{1-\eta}}[\sum_{i}(A_{i}[\frac{\bar{Q}}{Q_{i}}]^{1-\eta})^{\frac{1}{1-\alpha-\eta}}T_{i}]^{\frac{1-\alpha-\eta}{1-\eta}}$$

This step looks drastic to me. How can the aggregate output be derived from the above conditions?

Use $$W_{i}=V \cdot \frac{P_{i}^{\beta}}{Z_{i}}=VQ_i$$, then $$L_{i}=\left(\frac{\alpha^{1-\eta} \eta^{\eta}}{R^{\eta}} \cdot \frac{A_{i}}{(V_{i} Q_{i})^{1-\eta}}\right)^{\frac{1}{1-\alpha-\eta}} \cdot T_{i}$$ and $$\sum L_i = {\left({\frac{\alpha}{V}}\right)}^{\frac{1-\eta}{1-\alpha-\eta}} {\left({\frac{\eta}{R}}\right)}^{\frac{\eta}{1-\alpha-\eta}} \sum\left(\frac{A_i}{Q_i^{1-\eta}}\right)^{\frac{1}{1-\alpha-\eta}}T_i = 1$$ $$\frac{V}{\alpha} = {\left({\frac{\eta}{R}}\right)}^{\frac{\eta}{1-\eta}} \left(\sum\left(\frac{A_i}{Q_i^{1-\eta}}\right)^{\frac{1}{1-\alpha-\eta}}T_i\right)^{\frac{1-\alpha-\eta}{1-\eta}}$$.
Use the FOC on labor, $$W_i=\alpha \frac{Y_i}{L_i}$$, then $$\sum Y_i = \frac{V}{\alpha}\sum L_iQ_i = \frac{V}{\alpha} \bar{Q}$$, and replace $$\frac{V}{\alpha}$$ with above equation then you get equation (7).