#include #include using namespace std; int main(){ int N, K; cin >> N >> K; long nums[N]; for(int i = 0; i < N; i++){ cin >> nums[i]; cout << i << endl; } sort(nums, nums + N); long differences[N - 1]; for(int i = 0; i < N - 1; i++){ differences[i] = nums[i + 1] - nums[i]; cout << i << endl; } sort(differences, differences + N - 1); long ans = 0; for(int i = 0; i < N - K; i++){ ans += differences[i]; cout << i << endl; } cout << ans << endl; }