Problem:
I need to find the minimum of the expression: $$\sum_{k=1}^{n}a_{k}^{2}+\left(\sum_{k=1}^n a_k\right)^2$$ subject to the constraint: $$\sum_{k=1}^{n}p_{k}a_{k}=1$$ This problem can be solved using Cauchy-Schwarz inequality as follows: $$1=\sum_{k=1}^{n}p_{k}a_{k}=\sum_{k=1}^{n}(p_{k}-\beta )a_{k}+\beta (\sum_{k=1}^{n}a_{k})\leqslant (\sum_{k=1}^{n}(p_{k}-\beta )^{2}+\beta ^{2})((\sum_{k=1}^{n}a_{k}^{2})+(\sum_{k=1}^{n}a_{k})^{2})\Rightarrow \sum_{k=1}^{n}a_{k}^{2})+(\sum_{k=1}^{n}a_{k})^{2}\geqslant (\sum_{k=1}^{n}(p_{k}-\beta )^{2}+\beta ^{2})^{-1}$$ for any real $\beta$ . The value of $\beta$ that maximizes the expression: $\left(\sum_{k=1}^{n}(p_{k}-\beta )^2+\beta^2\right)^{-1}$ is : $\beta =\frac{1}{n+1}\sum_{k=1}^{n}p_{k}$ and the value of the expression for this particular value of $\beta$ is: $$\frac{n+1}{(n+1)\sum_{k=1}^{n}p_{k}^{2}-\left(\sum_{k=1}^{n}p_{k}\right)^{2}}$$
However, I am interested to see a solution busing the Lagrange Multipliers method. I considered: $$f(a_1,a_2,\ldots,a_n)=\sum_{k=1}^n a_k^2+\left(\sum_{k=1}^n a_k\right)^2$$
and $$g(a_{1},a_{2},\ldots,a_{n})=\sum_{k=1}^{n}p_{k}a_{k}=1$$
Then, I need to solve the system: $$\bigtriangledown f=\lambda \bigtriangledown g$$ together with $$g(a_{1},a_{2},\ldots,a_{n})=\sum_{k=1}^{n}p_{k}a_{k}=1$$. I found that $\lambda=2(\sum_{k=1}^{n}a_{k}^{2}+(\sum_{k=1}^{n}a_{k})^{2})$. But I couldn't find an explicit formula for $a_{k}$, $k=1,2,\ldots,n$. If anyone finds a way to solve this system, please share :)