#P2301. 就是干!

就是干!

Description

Seeing the massive army of teachers marching toward the computer lab, the LOI students decided to use their own strength to defend their good friend Loidc. Now everyone must choose their weapons—two wooden sticks. One is for long-range throwing, and the other is for close-quarters combat. Everyone wants the best, but that is impossible. To make most people satisfied and reduce conflict, cony designed a “conflict index.” This index is the sum of each person’s discomfort index, and the discomfort index is (L1L2)2(L1-L2)^2, where L1,L2L1, L2 are the lengths of the two sticks.

Cony decides to minimize the conflict index, so he comes to you for help and hopes you can tell him the minimum possible conflict index.

Input Format

The first line contains two integers m,nm,n.

It means there are nn people and mm sticks.

Then follow mm numbers representing each stick (it is guaranteed that a solution exists).

Output Format

A single number: the minimum conflict index.

5 2
3
1
4
5
8

5

Hint

Constraints: m2000,n500m \leq 2000, n \leq 500.

Translated by ChatGPT 5