#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  int t;
  cin >> t;
  while(t--){
    int n,k;
    cin >> n >> k;
    vector<int> dist;
    int pre;
    dist.push_back(0);
    REP(i,n){
      int tmp;
      cin >> tmp;
      if(i) dist.push_back(tmp-pre);
      pre=tmp;
    }
    SORT(dist);
    REP(i,n-1) dist[i+1]+=dist[i];
    cout << dist[max(n-k,0)] << endl;
  }
  return 0;
}