#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e10;   long long s[300005];   int main() {     int T;     long long n, k;     scanf( %d , &T);     while (T--) {       scanf( %lld %lld , &n, &k);       for (long long i = 1; i <= n; i++) scanf( %lld n , &s[i]);       long long ans = inf, v;       for (long long i = k + 1; i <= n; i++) {         if (ans > (s[i] - s[i - k])) ans = s[i] - s[i - k], v = i;       }       long long kk = (s[v] + s[v - k]) / 2;       cout << kk << endl;     }     return 0;   }   