#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(int i=0;i> N >> M; vector a(N); REP(i,N) cin >> a[i]; sort(a.begin(),a.end()); int p=-1; ll mn=1e18;; for(i=0;ia[i+M-1]-a[i]){ mn=a[i+M-1]-a[i]; p=i; } } ll S=0; for(i=p+1;i<=p+M-1;i++){ S+=(a[i]-a[i-1])*(a[i]-a[i-1]); } cout << S << endl; return 0; }