Ezzat has an array of $$$n$$$ integers (maybe negative). He wants to split it into two non-empty subsequences $$$a$$$ and $$$b$$$, such that every element from the array belongs to exactly one subsequence, and the value of $$$f(a) + f(b)$$$ is the maximum possible value, where $$$f(x)$$$ is the average of the subsequence $$$x$$$. A sequence $$$x$$$ is a subsequence of a sequence $$$y$$$ if $$$x$$$ can be obtained from $$$y$$$ by deletion of several (possibly, zero or all) elements.The average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.For example, the average of $$$[1,5,6]$$$ is $$$(1+5+6)/3 = 12/3 = 4$$$, so $$$f([1,5,6]) = 4$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^3$$$)— the number of test cases. Each test case consists of two lines. The first line contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3\cdot10^5$$$.

For each test case, print a single value — the maximum value that Ezzat can achieve. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$$$.

const MOD = Math.pow(10, 9) + 7;

function solve() {
   const [n] = readArray(Number);
   const bigN = BigInt(n);
   const arr = readArray((x) => BigInt(x) * 10000000n);
   arr.sort(sortF);
   let sum = 0n;
   for (let i = 0; i < n; i++) {
      sum += arr[i];
   }

   let curSum = arr[0];
   let ans = curSum + (sum - curSum) / (bigN - 1n);
   for (let i = 1; i < n - 1; i++) {
      curSum += arr[i];
      const counter = BigInt(i + 1);
      const curAns = curSum / counter + (sum - curSum) / (bigN - counter);
      if (curAns > ans) {
         ans = curAns;
      }
   }

   let full = ans / 10000000n;
   if (full < 0n) {
      full = -full;
   }
   const sign = (ans < 0n) ? '-' : '';
   let ost = ans % 10000000n;
   if (ost < 0n) {
      ost = -ost;
   }
   ost = '' + ost;
   while(ost.length < 7) {
      ost = '0' + ost;
   }
   write(sign + full + '.' + ost);
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1;
   while(curN) {
      if (curN & 1) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

const stdin = process.openStdin();
let content = '';

stdin.addListener('data', (data) => {
          content += data;
})

stdin.addListener('end', () => {
          content = content.split('\n');
          content.shift();
          content = content.map((string) => string.substring(0, string.length - 1));
          content.pop();
          let arr = [];
          content.forEach((string, i) => {
                    if (i % 2 === 1) {
                              arr.push(content[i]);
                    }
          })
          arr = arr.map((string) => string.split(' '));
          arr = arr.map((newArr) => newArr.map(num => parseInt(num)));
          arr = arr.map((newArr) => newArr.sort((a, b) => b - a));
          const max = new Array(arr.length).fill(Number.MIN_SAFE_INTEGER);
          arr.forEach((nums, i) => {
                    const cacheSum = [nums[0]];
                    for (let j = 1; j < nums.length; j++) {
                             cacheSum.push(cacheSum[cacheSum.length - 1] + nums[j]);
                    }
                    for (let j = 1; j < nums.length; j++) {
                              max[i] = Math.max(mean(0, j, cacheSum) + mean(j, nums.length, cacheSum), max[i]);
                    }
                    console.log(max[i]);
          })
})

const mean = (start, end, cacheSum) => {
          let sum = start !== 0 ? cacheSum[end - 1] - cacheSum[start - 1] : cacheSum[end - 1];
          return sum / (end - start);
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const assert = (condition) => { if (!condition) throw new Error("Assertion failed"); }
const mi = Math.min;
const mx = Math.max;
const mxll = (...args) => args.reduce((m, e) => e > m ? e : m);
const mill = (...args) => args.reduce((m, e) => e < m ? e : m);
const sqll = (v) => { if (v < 0n) throw 'negative input'; if (v < 2n) return v; const dfs = (n, x0) => { let x1 = ((n / x0) + x0) >> 1n; if (x0 === x1 || x0 === (x1 - 1n)) return x0; return dfs(n, x1); }; return dfs(v, 1n); }; // has >> 0
const abs = Math.abs;
const fl = Math.floor;
const int = parseInt;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg2 = Math.log2;
const lg10 = Math.log10;
const ll = BigInt;
const combination = (m, n) => { return factorial(m, n) / factorial(n, n); };
const factorial = (m, n) => { let num = 1n; let cnt = 0; for (let i = ll(m); i > 0; i--) { if (cnt == n) break; num *= i; cnt++; } return num; };
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const bitCount = (n) => { n = n - ((n >> 1) & 0x55555555); n = (n & 0x33333333) + ((n >> 2) & 0x33333333); return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
const powmod = (a, b, mod) => { let r = 1n; while (b > 0n) { if (b % 2n == 1) r = r * a % mod; b >>= 1n; a = a * a % mod; } return r; };
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const sortPart = (a, k) => { let l = a.slice(0, k); l.sort((x, y) => x - y); let r = a.slice(k); return l.concat(r); }; // sort first kth
const initialize2DArrayNew = (n, m) => { let data = []; for (let i = 0; i < n; i++) { let tmp = Array(m).fill(0); data.push(tmp); } return data; };
const initialize3DArray = (n, m, p) => { let res = []; for (let i = 0; i < n; i++) { let data = []; for (let j = 0; j < m; j++) { let tmp = new Array(p).fill(0); data.push(tmp); } res.push(data); } return res; };
const stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));
const stmkey_de = (m) => new Map([...m].sort((x, y) => y[0] - x[0]));
const stmvalue_in = (m) => new Map([...m].sort((x, y) => x[1] - y[1]));
const stmvalue_de = (m) => new Map([...m].sort((x, y) => y[1] - x[1]));
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const counter_value_in_indexA_in = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).push(i); } return m; };
const counter_value_in_indexA_de = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).unshift(i); } return m; };
const reverse2 = (s) => { let res = ""; for (let i = s.length - 1; i >= 0; i--) { res += s[i]; } return res; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
const ups = (s, i, c) => s.slice(0, i) + c + s.slice(i + 1);
const isSubsequence = (s, t) => { let sn = s.length; let tn = t.length; let i = j = 0; while (i < sn && j < tn) { if (s[i] == t[j]) { i++; j++; } else { i++; } } return j == tn; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const solve = (n, a) => {
    // pr(n, a)
    stin(a);
    let left = 0, right = sm(a), res = Number.MIN_SAFE_INTEGER;
    for (let i = 0; i < n - 1; i++) {
       left += a[i];
       right -= a[i];
       let nl = i + 1, nr = n - i - 1;
       // pr(left, nl, right, nr, left / nl + right / nr)
       res = mx(res, left / nl + right / nr)
    }
    pr(res.toFixed(9))
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i + 1]);
            i += 2;
        }
    });
};

main()

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var ans = 0;
            for(j = 0; j < e - 1; j++){
                ans += k[j];
            }
            ans /= e - 1;
            ans += k[e - 1];
            console.log(ans);
        }
    }
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var ans = 0;
            for(j = 0; j < e - 1; j++){
                ans += k[j];
            }
            ans /= e - 1;
            ans += k[e - 1];
            console.log(ans.toPrecision(10));
        }
    }
});

// --------------- TEMPLATE START ---------------
const rl = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

const nextLine = () => {
  const nextLineGen = (async function* () {
    for await (const line of rl) {
      yield line.trim();
    }
  }());
  return (async () => {
    const next = await nextLineGen.next();
    return next.value;
  })();
};

const nextNum = async () => {
  const line = await nextLine();
  return Number(line);
};

const nextNumArr = async () => {
  const line = await nextLine();
  return line.split(" ").map((num) => Number(num));
};
// --------------- TEMPLATE END ---------------

const ezzatAndTwoSubsequences = async () => {
  let t = await nextNum();

  while (t-- > 0) {
    let n = await nextNum();
    let arr = await nextNumArr();

    let top = Math.max(...arr);
    let sum = 0;
    for(let i = 0; i < n; i++) {
      sum += arr[i];
    }

    console.log((sum - top) / (n-1) + top);
  }
};

ezzatAndTwoSubsequences();

// --------------- TEMPLATE START ---------------
const rl = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

const nextLine = () => {
  const nextLineGen = (async function* () {
    for await (const line of rl) {
      yield line.trim();
    }
  }());
  return (async () => {
    const next = await nextLineGen.next();
    return next.value;
  })();
};

const nextNum = async () => {
  const line = await nextLine();
  return Number(line);
};

const nextNumArr = async () => {
  const line = await nextLine();
  return line.split(" ").map((num) => Number(num));
};
// --------------- TEMPLATE END ---------------

const ezzatAndTwoSubsequences = async () => {
  let t = await nextNum();

  while (t-- > 0) {
    let n = await nextNum();
    let arr = await nextNumArr();

    arr.sort((a, b) => a - b);

    let sum = 0;
    for(let i = 0; i < n-1; i++) {
      sum += arr[i];
    }

    console.log(sum / (n-1) + arr[n-1]);
  }
};

ezzatAndTwoSubsequences();

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let n = nl.num();
		let a = nl.nums();
		let m = a.reduce((ac, e) => e > ac?e:ac, a[0]);
		let s = a.reduce((ac, e) => ac + e, 0) - m;
		ans.push(((s / (n - 1)) + m).toFixed(9));
	}
	console.log(ans.join('\n'));

};

process.stdin.on('end', sol);

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return a - b;
		});
		var sum = 0;
		for(var i = 0; i < N - 1; i++){
			sum += list[i];
		}
		sum /= N - 1;
		myout(sum + list[N - 1]);
	}
}

// function calculateAvg(array) {
//   let result = 0;
//   for (let i = 0; i < array.length; i++) {
//     result += array[i];
//   }
//   return result / (array.length);
// }
// function getMax(array) {
//   let max = array[0];
//   for (let i = 1; i < array.length; i++) {
//     if (max < array[i]) max = array[i];
//   }
//   return max;
// }

function max(list) {
  let res = list[0]
  for (let i = 0; i < list.length; i++) {
    if (res < list[i]) {
      res = list[i]
    }
  }

  return res
}

function min(list) {
  let res = list[0]
  for (let i = 0; i < list.length; i++) {
    if (res > list[i]) {
      res = list[i]
    }
  }
  return res
}

function solve(n, list) {
  let res = 0
  for (let i = 0; i < n; i++) {
    res += list[i];
  }
  const maxValue = max(list);
  res -= maxValue;
  return res / (n - 1) + maxValue;
}
function main(array) {
  const T = array[0];
  for (let i = 0; i < T; i++) {
    const n = array[i * 2 + 1];
    const list = array[(i + 1) * 2];
    const res = solve(n, list.split(' ').map((item) => parseInt(item, 10)));
    console.log(res);
    // console.log(res)
  }
}

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString.trim().split('\n').map((string) => string.trim());

  main(inputString);
});

let examplesStrings = [
`4
3
3 1 2
3
-7 -6 -6
3
2 2 2
4
17 3 5 -3`,
// `3
// 1 2 3`,
// `9
// 1 2 1 3 2 2 2 2 3`
];

let examples = [
    [
        [3,1,2],
        [-7, -6, -6],
        [2,2,2],
        [17,3,5,-3]
    ],
    // [1,2,3],
    // [1,2,1,3,2,2,2,2,3]
];

let answers = [
`4.5
-12.5
4
18.666666667`
// `2`,
// `4`,
// '10'
];

//

const parser = (string) => {
    const lines = string.match(/[^\r\n]+/g);

    // return lines[1].split(' ').map(x => parseInt(x, 10))

    const finalResult = [];
    for(let i = 2; i < lines.length; i+=2) {
        finalResult.push(lines[i].split(' ').map(x => parseInt(x, 10)))
    }
    return finalResult;
}

const solver = (arr2d) => {
    return arr2d.map(arr => {
        arr.sort((a,b) => b-a);

        console.log(arr);
        return arr[0] + arr.slice(1).reduce((a,b) => a+b, 0) / (arr.length - 1)
    }).join("\r\n")

};

const multiSolver = (_inputs) => {
    const isMulti = false;

    const inputs = isMulti ? _inputs : [_inputs];

    let results = [];
    for(let input of inputs) {
        results.push(solver(input));
        // logResult(solver(input))
    }
    console.log({results})
    const strResults = results.join("\r\n");
    logResult(strResults);
    return strResults;

}

// FINISH HERE !!!
// STOP
// STOP

const isDevMode = process.env.LOCAL === 'knotri';
const logResult = console.log;

const deepEq = (obj1, obj2) => JSON.stringify(obj1) === JSON.stringify(obj2)
const validate = ({examplesStrings, examples, answers, parser, multiSolver}) => {
    examplesStrings.forEach((string, index) => {
        const actualParse = parser(string);
        const desiredParse = examples[index];

        if (!deepEq(actualParse, desiredParse)) {
            console.error('PARSE WRONG!');
            console.log({actualParse, desiredParse})
        }

        const actualAnswer = multiSolver(actualParse);
        const desiredAnswer = answers[index];

        if (!deepEq(actualAnswer, desiredAnswer)) {
            console.error('SOLVE WRONG!');
            console.log({actualParse, actualAnswer, desiredAnswer})
        }

    });

}

if (!isDevMode) {
    console.log = () => {};
    const fs = require("fs");
    const stdinBuffer = fs.readFileSync(0);
    const string = stdinBuffer.toString();

    multiSolver(parser(string));
} else {
    validate({examplesStrings, examples, answers, parser, multiSolver})
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main()
});

function readline() {
  return inputString[currentLine++]
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // console.time('Execution Time')
  let testCases = readline()
  while(testCases--)
    solve()
  // console.timeEnd('Execution Time');
}

// function to solve problems
function solve (){
  let n = readline()
  let arr = readline().split(' ').map(x => +x)
  let fa = Math.max(...arr)
  let fb = arr.reduce((num, sum) => sum += num)
  fb -= fa
  fb = (fb/(arr.length - 1))
  console.log(fa + fb)
}

function sortAscending(a, b) {
  return a[0] - b[0]
}
// String.prototype.replaceAt = function (index, replacement) {
//   return this.substring(0, index) + replacement + this.substring(index + replacement.length)
// }

const MOD = Math.pow(10, 9) + 7;

function solve() {
   const [n] = readArray(Number);
   const bigN = BigInt(n);
   const arr = readArray((x) => BigInt(x) * 10000000n);
   arr.sort(sortF);
   let sum = 0n;
   for (let i = 0; i < n; i++) {
      sum += arr[i];
   }

   let curSum = arr[0];
   let ans = curSum + (sum - curSum) / (bigN - 1n);
   for (let i = 1; i < n - 1; i++) {
      curSum += arr[i];
      const counter = BigInt(i + 1);
      const curAns = curSum / counter + (sum - curSum) / (bigN - counter);
      if (curAns > ans) {
         ans = curAns;
      }
   }

   const full = ans / 10000000n;
   if (full < 0n) {
      full = -full;
   }
   const sign = (ans < 0n) ? '0' : '';
   let ost = ans % 10000000n;
   if (ost < 0n) {
      ost = -ost;
   }
   ost = '' + ost;
   while(ost.length < 7) {
      ost = '0' + ost;
   }
   write(sign + full + '.' + ost);
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1;
   while(curN) {
      if (curN & 1) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

const MOD = Math.pow(10, 9) + 7;

function solve() {
   const [n] = readArray(Number);
   const bigN = BigInt(n);
   const arr = readArray((x) => BigInt(x) * 10000000n);
   arr.sort(sortF);
   let sum = 0n;
   for (let i = 0; i < n; i++) {
      sum += arr[i];
   }

   let curSum = arr[0];
   let ans = curSum + (sum - curSum) / (bigN - 1n);
   for (let i = 1; i < n - 1; i++) {
      curSum += arr[i];
      const counter = BigInt(i + 1);
      const curAns = curSum / counter + (sum - curSum) / (bigN - counter);
      if (curAns > ans) {
         ans = curAns;
      }
   }

   const full = ans / 10000000n;
   let ost = ans % 10000000n;
   if (ost < 0) {
      ost = -ost;
   }
   ost = '' + ost;
   while(ost.length < 7) {
      ost = '0' + ost;
   }
   write(full + '.' + ost);
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1;
   while(curN) {
      if (curN & 1) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

const MOD = Math.pow(10, 9) + 7;

function solve() {
   const [n] = readArray(Number);
   const arr = readArray(BigInt);
   let maxi = arr[0];
   let sum = 0n;
   for (let i = 0; i < n; i++) {
      sum += arr[i];
      if (arr[i] > maxi) {
         maxi = arr[i];
      }
   }
   const bigN = BigInt(n);
   sum -= maxi;
   const ans = sum * 100000000n / (bigN - 1n) + maxi * 100000000n;
   const full = ans / 100000000n;
   let ost = '' + (ans % 100000000n + (ans < 0n ? 100000000n : 0n));
   while(ost.length < 8) {
      ost = '0' + ost;
   }
   write(full + '.' + ost);
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1;
   while(curN) {
      if (curN & 1) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

const MOD = Math.pow(10, 9) + 7;

function solve() {
   const [n] = readArray(Number);
   const arr = readArray(BigInt);
   let maxi = arr[0];
   let sum = 0n;
   for (let i = 0; i < n; i++) {
      sum += arr[i];
      if (arr[i] > maxi) {
         maxi = arr[i];
      }
   }
   const bigN = BigInt(n);
   sum -= maxi;
   const ans = sum * 10000000n / (bigN - 1n) + maxi * 10000000n;
   const full = ans / 10000000n;
   let ost = '' + (ans % 10000000n + (ans < 0n ? 10000000n : 0n));
   while(ost.length < 7) {
      ost = '0' + ost;
   }
   write(full + '.' + ost);
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1;
   while(curN) {
      if (curN & 1) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

const stdin = process.openStdin();
let content = '';

stdin.addListener('data', (data) => {
          content += data;
})

stdin.addListener('end', () => {
          content = content.split('\n');
          content.shift();
          content = content.map((string) => string.substring(0, string.length - 1));
          content.pop();
          let arr = [];
          content.forEach((string, i) => {
                    if (i % 2 === 1) {
                              arr.push(content[i]);
                    }
          })
          arr = arr.map((string) => string.split(' '));
          arr = arr.map((newArr) => newArr.map(num => parseInt(num)));
          arr = arr.map((newArr) => newArr.sort((a, b) => b - a));
          const max = new Array(arr.length).fill(Number.MIN_SAFE_INTEGER);
          arr.forEach((nums, i) => {
                    for (let j = 1; j < nums.length; j++) {
                              max[i] = Math.max(mean(nums.slice(0, j)) + mean(nums.slice(j)), max[i]);
                    }
          })
          console.log(arr, max)
})

const mean = (arr) => {
          if (arr.length === 0) return 0;
          let sum = 0;
          arr.forEach(num => {
                  sum += num;
          })
          return sum / arr.length;
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const assert = (condition) => { if (!condition) throw new Error("Assertion failed"); }
const mi = Math.min;
const mx = Math.max;
const mxll = (...args) => args.reduce((m, e) => e > m ? e : m);
const mill = (...args) => args.reduce((m, e) => e < m ? e : m);
const sqll = (v) => { if (v < 0n) throw 'negative input'; if (v < 2n) return v; const dfs = (n, x0) => { let x1 = ((n / x0) + x0) >> 1n; if (x0 === x1 || x0 === (x1 - 1n)) return x0; return dfs(n, x1); }; return dfs(v, 1n); }; // has >> 0
const abs = Math.abs;
const fl = Math.floor;
const int = parseInt;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg2 = Math.log2;
const lg10 = Math.log10;
const ll = BigInt;
const combination = (m, n) => { return factorial(m, n) / factorial(n, n); };
const factorial = (m, n) => { let num = 1n; let cnt = 0; for (let i = ll(m); i > 0; i--) { if (cnt == n) break; num *= i; cnt++; } return num; };
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const bitCount = (n) => { n = n - ((n >> 1) & 0x55555555); n = (n & 0x33333333) + ((n >> 2) & 0x33333333); return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
const powmod = (a, b, mod) => { let r = 1n; while (b > 0n) { if (b % 2n == 1) r = r * a % mod; b >>= 1n; a = a * a % mod; } return r; };
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const sortPart = (a, k) => { let l = a.slice(0, k); l.sort((x, y) => x - y); let r = a.slice(k); return l.concat(r); }; // sort first kth
const initialize2DArrayNew = (n, m) => { let data = []; for (let i = 0; i < n; i++) { let tmp = Array(m).fill(0); data.push(tmp); } return data; };
const initialize3DArray = (n, m, p) => { let res = []; for (let i = 0; i < n; i++) { let data = []; for (let j = 0; j < m; j++) { let tmp = new Array(p).fill(0); data.push(tmp); } res.push(data); } return res; };
const stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));
const stmkey_de = (m) => new Map([...m].sort((x, y) => y[0] - x[0]));
const stmvalue_in = (m) => new Map([...m].sort((x, y) => x[1] - y[1]));
const stmvalue_de = (m) => new Map([...m].sort((x, y) => y[1] - x[1]));
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const counter_value_in_indexA_in = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).push(i); } return m; };
const counter_value_in_indexA_de = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).unshift(i); } return m; };
const reverse2 = (s) => { let res = ""; for (let i = s.length - 1; i >= 0; i--) { res += s[i]; } return res; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
const ups = (s, i, c) => s.slice(0, i) + c + s.slice(i + 1);
const isSubsequence = (s, t) => { let sn = s.length; let tn = t.length; let i = j = 0; while (i < sn && j < tn) { if (s[i] == t[j]) { i++; j++; } else { i++; } } return j == tn; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const solve = (n, a) => {
    // pr(n, a)
    let left = 0, right = sm(a), res = Number.MIN_SAFE_INTEGER;
    for (let i = 0; i < n - 1; i++) {
       left += a[i];
       right -= a[i];
       let nl = i + 1, nr = n - i - 1;
       // pr(left, nl, right, nr)
       res = mx(res, left / nl + right / nr)
    }
    pr(res.toFixed(9))
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i + 1]);
            i += 2;
        }
    });
};

main()

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const assert = (condition) => { if (!condition) throw new Error("Assertion failed"); }
const mi = Math.min;
const mx = Math.max;
const mxll = (...args) => args.reduce((m, e) => e > m ? e : m);
const mill = (...args) => args.reduce((m, e) => e < m ? e : m);
const sqll = (v) => { if (v < 0n) throw 'negative input'; if (v < 2n) return v; const dfs = (n, x0) => { let x1 = ((n / x0) + x0) >> 1n; if (x0 === x1 || x0 === (x1 - 1n)) return x0; return dfs(n, x1); }; return dfs(v, 1n); }; // has >> 0
const abs = Math.abs;
const fl = Math.floor;
const int = parseInt;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg2 = Math.log2;
const lg10 = Math.log10;
const ll = BigInt;
const combination = (m, n) => { return factorial(m, n) / factorial(n, n); };
const factorial = (m, n) => { let num = 1n; let cnt = 0; for (let i = ll(m); i > 0; i--) { if (cnt == n) break; num *= i; cnt++; } return num; };
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const bitCount = (n) => { n = n - ((n >> 1) & 0x55555555); n = (n & 0x33333333) + ((n >> 2) & 0x33333333); return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
const powmod = (a, b, mod) => { let r = 1n; while (b > 0n) { if (b % 2n == 1) r = r * a % mod; b >>= 1n; a = a * a % mod; } return r; };
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const sortPart = (a, k) => { let l = a.slice(0, k); l.sort((x, y) => x - y); let r = a.slice(k); return l.concat(r); }; // sort first kth
const initialize2DArrayNew = (n, m) => { let data = []; for (let i = 0; i < n; i++) { let tmp = Array(m).fill(0); data.push(tmp); } return data; };
const initialize3DArray = (n, m, p) => { let res = []; for (let i = 0; i < n; i++) { let data = []; for (let j = 0; j < m; j++) { let tmp = new Array(p).fill(0); data.push(tmp); } res.push(data); } return res; };
const stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));
const stmkey_de = (m) => new Map([...m].sort((x, y) => y[0] - x[0]));
const stmvalue_in = (m) => new Map([...m].sort((x, y) => x[1] - y[1]));
const stmvalue_de = (m) => new Map([...m].sort((x, y) => y[1] - x[1]));
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const counter_value_in_indexA_in = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).push(i); } return m; };
const counter_value_in_indexA_de = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).unshift(i); } return m; };
const reverse2 = (s) => { let res = ""; for (let i = s.length - 1; i >= 0; i--) { res += s[i]; } return res; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
const ups = (s, i, c) => s.slice(0, i) + c + s.slice(i + 1);
const isSubsequence = (s, t) => { let sn = s.length; let tn = t.length; let i = j = 0; while (i < sn && j < tn) { if (s[i] == t[j]) { i++; j++; } else { i++; } } return j == tn; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const solve = (n, a) => {
    // pr(n, a)
    let left = 0, sum = sm(a), res = Number.MIN_SAFE_INTEGER;
    for (let i = 0; i < n; i++) {
       left += a[i];
       sum -= a[i];
       // pr(left / (i + 1), sum / (n - i - 1))
       if (n - i - 1 > 0) res = mx(res, left / (i + 1) + sum / (n - i - 1))
    }
    pr(res)
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i + 1]);
            i += 2;
        }
    });
};

main()


Suppose you are living with two cats: A and B. There are $$$n$$$ napping spots where both cats usually sleep.Your cats like to sleep and also like all these spots, so they change napping spot each hour cyclically:   Cat A changes its napping place in order: $$$n, n - 1, n - 2, \dots, 3, 2, 1, n, n - 1, \dots$$$ In other words, at the first hour it's on the spot $$$n$$$ and then goes in decreasing order cyclically;  Cat B changes its napping place in order: $$$1, 2, 3, \dots, n - 1, n, 1, 2, \dots$$$ In other words, at the first hour it's on the spot $$$1$$$ and then goes in increasing order cyclically. The cat B is much younger, so they have a strict hierarchy: A and B don't lie together. In other words, if both cats'd like to go in spot $$$x$$$ then the A takes this place and B moves to the next place in its order (if $$$x < n$$$ then to $$$x + 1$$$, but if $$$x = n$$$ then to $$$1$$$). Cat B follows his order, so it won't return to the skipped spot $$$x$$$ after A frees it, but will move to the spot $$$x + 2$$$ and so on.Calculate, where cat B will be at hour $$$k$$$?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first and only line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$; $$$1 \le k \le 10^9$$$) — the number of spots and hour $$$k$$$.

For each test case, print one integer — the index of the spot where cat B will sleep at hour $$$k$$$.

NoteIn the first and second test cases $$$n = 2$$$, so:   at the $$$1$$$-st hour, A is on spot $$$2$$$ and B is on $$$1$$$;  at the $$$2$$$-nd hour, A moves to spot $$$1$$$ and B — to $$$2$$$.  If $$$n = 3$$$ then:   at the $$$1$$$-st hour, A is on spot $$$3$$$ and B is on $$$1$$$;  at the $$$2$$$-nd hour, A moves to spot $$$2$$$; B'd like to move from $$$1$$$ to $$$2$$$, but this spot is occupied, so it moves to $$$3$$$;  at the $$$3$$$-rd hour, A moves to spot $$$1$$$; B also would like to move from $$$3$$$ to $$$1$$$, but this spot is occupied, so it moves to $$$2$$$. In the sixth test case:   A's spots at each hour are $$$[5, 4, 3, 2, 1]$$$;  B's spots at each hour are $$$[1, 2, 4, 5, 2]$$$.

/*
 * File Created: Tuesday, 16th February 2021 2:01:47 pm
 * Author: Lukas Rimkus
 */

 'use-strict'

 process.stdin.resume();
 process.stdin.setEncoding('utf8');

 let data = '';
 let currentLine = 0;

 process.stdin.on('data', chunk => {
 data += chunk;
 });

 process.stdin.on('end', () =>{
     data = data.replace(/\s*$/, '')
     .split('\n')
     .map(str => str.replace(/\s*$/, ''));

     let testCases = parseInt(data.shift());

     while(testCases--) {

         const [n,k] = readLine().split(' ').map(Number);

         b(n,k);
     }
 });

 function get_ints() {
     return data.shift().split(' ').map(Number);
 }

 function readLine() {
         return data[currentLine++];
 }

 function a(n,a){
     a.sort((a,b) => a - b);
     let count = 0;
     for(let i = 0 ; i < n; i++){
         if(i === n - 1) break;
         if(a[i] !== a[i+1]){
             return n - i - 1;
         }
     }
     return 0;
 }

function b(n,k){
    const f = Math.floor(n / 2);
    k--;
    const ans = (k + (n % 2) * Math.floor(k/f))
    return console.log(ans % n + 1)

}

module.exports = b;

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var x = Number(readline())
    Array(Number(x)).fill(1).map((t, i) => {

        var [n, k] = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        if (n % 2 === 0) {
            if(k % n ===0) return console.log(n)
            return console.log(k % n)
        }
        var mid = Math.floor(n/2)
        var res = Math.floor((k-1) / mid)

        // console.log((k+res)%(n))
        // console.log(res, k, mid)
        if(k<mid) return console.log(k)
        if ((k + res) % (n) === 0) return console.log(n)
        console.log((k + res) % (n))
    })

}

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let t = rn();
	while (t--) {
		let [n, k] = rna();

		if (n % 2)
			k += Math.floor((k - 1)/Math.floor(n / 2));

		const ans = (k - 1) % n + 1;

		console.log(ans);
	}
}

/*
 * File Created: Tuesday, 16th February 2021 2:01:47 pm
 * Author: Lukas Rimkus
 */

 'use-strict'

 process.stdin.resume();
 process.stdin.setEncoding('utf8');

 let data = '';
 let currentLine = 0;

 process.stdin.on('data', chunk => {
 data += chunk;
 });

 process.stdin.on('end', () =>{
     data = data.replace(/\s*$/, '')
     .split('\n')
     .map(str => str.replace(/\s*$/, ''));

     let testCases = parseInt(data.shift());

     while(testCases--) {

         const [n,k] = readLine().split(' ').map(Number);

         const res = b(n,k);

         console.log(res)
     }
 });

 function get_ints() {
     return data.shift().split(' ').map(Number);
 }

 function readLine() {
         return data[currentLine++];
 }

 function a(n,a){
     a.sort((a,b) => a - b);
     let count = 0;
     for(let i = 0 ; i < n; i++){
         if(i === n - 1) break;
         if(a[i] !== a[i+1]){
             return n - i - 1;
         }
     }
     return 0;
 }

function b(n,k){
    let a = n;
    let b = 1;
    if(n % 2 === 0){
        // they don't meet each other
        if(n === k) return k;
        else if(n > k){
            return k;
        } else {
            return k % n;
        }
    } else {
        // they meet each other every 2 times in every cycle: ->
        // how many cycles?
        if(n === k){
            return b + 1;
        } else if(n > k){
            const middle = Math.ceil(n / 2);
            if(middle > k){
                return k;
            } else {
                return k + 1;
            }
        } else {
            const cycle = Math.floor(k / n);
            let rem = k % n - 1;
            // how many diff seq?
            const seq = Math.floor(n / 2);
            b = 1 + Math.min(seq,cycle) * 2;
            if(b === n) b = 1;
            for(let a = n; rem > 0; a--, rem--,b++){

                if(a === b) b++;
                // console.log(`${a}, ${rem}, ${b}`)
            }
            return b;
        }
    }
}

module.exports = b;

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var x = Number(readline())
    Array(Number(x)).fill(1).map((t, i) => {

        var [n, k] = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        if (n % 2 === 0) return console.log((k) % (n + 1))
        var mid = Math.floor(n/2)
        var res = Math.floor((k-1) / mid)

        // console.log((k+res)%(n))
        // console.log(res, k, mid)
        if(k<mid) return console.log(k)
        if ((k + res) % (n) === 0) return console.log(n)
        console.log((k + res) % (n))
    })

}

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}


Suppose $$$a_1, a_2, \dots, a_n$$$ is a sorted integer sequence of length $$$n$$$ such that $$$a_1 \leq a_2 \leq \dots \leq a_n$$$. For every $$$1 \leq i \leq n$$$, the prefix sum $$$s_i$$$ of the first $$$i$$$ terms $$$a_1, a_2, \dots, a_i$$$ is defined by $$$$$$ s_i = \sum_{k=1}^i a_k = a_1 + a_2 + \dots + a_i. $$$$$$Now you are given the last $$$k$$$ terms of the prefix sums, which are $$$s_{n-k+1}, \dots, s_{n-1}, s_{n}$$$. Your task is to determine whether this is possible. Formally, given $$$k$$$ integers $$$s_{n-k+1}, \dots, s_{n-1}, s_{n}$$$, the task is to check whether there is a sequence $$$a_1, a_2, \dots, a_n$$$ such that   $$$a_1 \leq a_2 \leq \dots \leq a_n$$$, and  $$$s_i = a_1 + a_2 + \dots + a_i$$$ for all $$$n-k+1 \leq i \leq n$$$.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains two integers $$$n$$$ ($$$1 \leq n \leq 10^5$$$) and $$$k$$$ ($$$1 \leq k \leq n$$$), indicating the length of the sequence $$$a$$$ and the number of terms of prefix sums, respectively. The second line of each test case contains $$$k$$$ integers $$$s_{n-k+1}, \dots, s_{n-1}, s_{n}$$$ ($$$-10^9 \leq s_i \leq 10^9$$$ for every $$$n-k+1 \leq i \leq n$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output "YES" (without quotes) if it is possible and "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

NoteIn the first test case, we have the only sequence $$$a = [1, 1, 1, 1, 1]$$$.In the second test case, we can choose, for example, $$$a = [-3, -2, -1, 0, 1, 2, 3]$$$.In the third test case, the prefix sums define the only sequence $$$a = [2, 1, 1]$$$, but it is not sorted. In the fourth test case, it can be shown that there is no sequence with the given prefix sums.

var gcd = function(x, y){
    while(y){
        var t = y;
        y = x % y;
        x = t;
    }
return x;
};
var MC = function(a){
    return Math.ceil(a);
};
var MF = function(a){
    return Math.floor(a);
};
var Mi = function(a, b){
    return Math.min(a, b);
};
var Ma = function(a, b){
    return Math.max(a, b);
};
var check = function(a){
    for(c = 2; c <= Math.sqrt(a); c++){
        if(a % c === 0){
            return false;
        }
    }
    return true;
};
let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        var s = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = s[0], k = s[1];
        }else{
            var ok = true;
            var a = 2e9;
            for(j = k - 1; j > 0; j--){
                if(s[j] - s[j - 1] > a){
                    ok = false;
                }
                a = s[j] - s[j - 1];
            }
            if((n - k + 1) * a < s[0]){
                ok = false;
            }
            console.log(ok ? 'YES' : 'NO');
        }
    }
});

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

function readLine() {
    return inputString[currentLine++];
}

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const n_k = readLine().split(' ').map(p => +p);
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(n_k[0], n_k[1], arr);
        console.log(result);
    }
}

function myFunc(n, k, arr){
    if(k == 1) return 'YES';

    let min = Infinity;
    for(let i = k-1; i > 0; i--){
        if(arr[i] - arr[i-1] > min) return 'NO';
        min = arr[i] - arr[i-1];
    }

    // if(arr[0] > min) return 'NO';
    if( (n-k+1) * min < arr[0]) return 'NO';

    return 'YES';

}

var gcd = function(x, y){
    while(y){
        var t = y;
        y = x % y;
        x = t;
    }
return x;
};
var MC = function(a){
    return Math.ceil(a);
};
var MF = function(a){
    return Math.floor(a);
};
var Mi = function(a, b){
    return Math.min(a, b);
};
var Ma = function(a, b){
    return Math.max(a, b);
};
var check = function(a){
    for(c = 2; c <= Math.sqrt(a); c++){
        if(a % c === 0){
            return false;
        }
    }
    return true;
};
let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        var s = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = s[0], k = s[1];
        }else{
            var ok = true;
            var a = 1e9;
            for(j = k - 1; j > 0; j--){
                if(s[j] - s[j - 1] > a){
                    ok = false;
                }
                a = s[j] - s[j - 1];
            }
            if((n - k + 1) * a < s[0]){
                ok = false;
            }
            console.log(ok ? 'YES' : 'NO');
        }
    }
});

var gcd = function(x, y){
    while(y){
        var t = y;
        y = x % y;
        x = t;
    }
return x;
};
var MC = function(a){
    return Math.ceil(a);
};
var MF = function(a){
    return Math.floor(a);
};
var Mi = function(a, b){
    return Math.min(a, b);
};
var Ma = function(a, b){
    return Math.max(a, b);
};
var check = function(a){
    for(c = 2; c <= Math.sqrt(a); c++){
        if(a % c === 0){
            return false;
        }
    }
    return true;
};
let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        var s = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = s[0], k = s[1];
        }else{
            var ok = true;
            var a = 1e5;
            for(j = k - 1; j > 0; j--){
                if(s[j] - s[j - 1] > a){
                    ok = false;
                }
                a = s[j] - s[j - 1];
            }
            if((n - k + 1) * a < s[0]){
                ok = false;
            }
            console.log(ok ? 'YES' : 'NO');
        }
    }
});

var gcd = function(x, y){
    while(y){
        var t = y;
        y = x % y;
        x = t;
    }
return x;
};
var MC = function(a){
    return Math.ceil(a);
};
var MF = function(a){
    return Math.floor(a);
};
var Mi = function(a, b){
    return Math.min(a, b);
};
var Ma = function(a, b){
    return Math.max(a, b);
};
var check = function(a){
    for(c = 2; c <= Math.sqrt(a); c++){
        if(a % c === 0){
            return false;
        }
    }
    return true;
};
let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        var s = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = s[0], k = s[1];
        }else{
            var ok = true;
            var a = 1e3;
            for(j = k - 1; j > 0; j--){
                if(s[j] - s[j - 1] > a){
                    ok = false;
                }
                a = s[j] - s[j - 1];
            }
            if((n - k + 1) * a < s[0]){
                ok = false;
            }
            console.log(ok ? 'YES' : 'NO');
        }
    }
});

var gcd = function(x, y){
    while(y){
        var t = y;
        y = x % y;
        x = t;
    }
return x;
};
var MC = function(a){
    return Math.ceil(a);
};
var MF = function(a){
    return Math.floor(a);
};
var Mi = function(a, b){
    return Math.min(a, b);
};
var Ma = function(a, b){
    return Math.max(a, b);
};
var check = function(a){
    for(c = 2; c <= Math.sqrt(a); c++){
        if(a % c === 0){
            return false;
        }
    }
    return true;
};
let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        var s = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = s[0], k = s[1];
        }else{
            var ok = true;
            var a = 100;
            for(j = k - 1; j > 0; j--){
                if(s[j] - s[j - 1] > a){
                    ok = false;
                }
                a = s[j] - s[j - 1];
            }
            if((n - k + 1) * a < s[0]){
                ok = false;
            }
            console.log(ok ? 'YES' : 'NO');
        }
    }
});

var gcd = function(x, y){
    while(y){
        var t = y;
        y = x % y;
        x = t;
    }
return x;
};
var MC = function(a){
    return Math.ceil(a);
};
var MF = function(a){
    return Math.floor(a);
};
var Mi = function(a, b){
    return Math.min(a, b);
};
var Ma = function(a, b){
    return Math.max(a, b);
};
var check = function(a){
    for(c = 2; c <= Math.sqrt(a); c++){
        if(a % c === 0){
            return false;
        }
    }
    return true;
};
let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        var s = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = s[0], k = s[1];
        }else{
            var ok = true;
            var a = 10;
            for(j = k - 1; j > 0; j--){
                if(s[j] - s[j - 1] > a){
                    ok = false;
                }
                a = s[j] - s[j - 1];
            }
            if((n - k + 1) * a < s[0]){
                ok = false;
            }
            console.log(ok ? 'YES' : 'NO');
        }
    }
});

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

function readLine() {
    return inputString[currentLine++];
}

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const n_k = readLine().split(' ').map(p => +p);
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(n_k[0], n_k[1], arr);
        console.log(result);
    }
}

function myFunc(n, k, arr){

    let min = Infinity;
    for(let i = k-1; i > 0; i--){
        if(arr[i] - arr[i-1] > min) return 'NO';
        min = arr[i] - arr[i-1];
    }

    if(arr[0] > min) return 'NO';
    if( (n-k+1) * min < min) return 'NO';

    return 'YES';

}


You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied:  The length of $$$s$$$ is $$$1$$$, and it consists of the character $$$c$$$ (i.e. $$$s_1=c$$$); The length of $$$s$$$ is greater than $$$1$$$, the first half of the string consists of only the character $$$c$$$ (i.e. $$$s_1=s_2=\dots=s_{\frac{n}{2}}=c$$$) and the second half of the string (i.e. the string $$$s_{\frac{n}{2} + 1}s_{\frac{n}{2} + 2} \dots s_n$$$) is a $$$(c+1)$$$-good string;  The length of $$$s$$$ is greater than $$$1$$$, the second half of the string consists of only the character $$$c$$$ (i.e. $$$s_{\frac{n}{2} + 1}=s_{\frac{n}{2} + 2}=\dots=s_n=c$$$) and the first half of the string (i.e. the string $$$s_1s_2 \dots s_{\frac{n}{2}}$$$) is a $$$(c+1)$$$-good string. For example: "aabc" is 'a'-good, "ffgheeee" is 'e'-good.In one move, you can choose one index $$$i$$$ from $$$1$$$ to $$$n$$$ and replace $$$s_i$$$ with any lowercase Latin letter (any character from 'a' to 'z').Your task is to find the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string for $$$c=$$$ 'a'). It is guaranteed that the answer always exists.You have to answer $$$t$$$ independent test cases.Another example of an 'a'-good string is as follows. Consider the string $$$s = $$$"cdbbaaaa". It is an 'a'-good string, because:  the second half of the string ("aaaa") consists of only the character 'a';  the first half of the string ("cdbb") is 'b'-good string, because:   the second half of the string ("bb") consists of only the character 'b';  the first half of the string ("cd") is 'c'-good string, because:   the first half of the string ("c") consists of only the character 'c';  the second half of the string ("d") is 'd'-good string.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) — the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$. The second line of the test case contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. It is guaranteed that the sum of $$$n$$$ does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

For each test case, print the answer — the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists.

6
8
bbdcaaaa
8
asdfghjk
8
ceaaaabb
8
bbaaddcc
1
z
2
ac

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const str = readLine();
    console.log(solve(0, len - 1, "a"));

    function solve(start, end, char) {
      if (start === end) return +(str[start] !== char);

      let count1 = 0;
      for (let i = start; i <= Math.floor((start + end) / 2); i++) if (str[i] !== char) count1++;
      let _count1 = solve(Math.floor((start + end) / 2) + 1, end, String.fromCharCode(char.charCodeAt(0) + 1));

      let count2 = 0;
      for (let i = Math.floor((start + end) / 2) + 1; i <= end; i++) if (str[i] !== char) count2++;
      let _count2 = solve(start, Math.floor((start + end) / 2), String.fromCharCode(char.charCodeAt(0) + 1));

      return Math.min(count1 + _count1, count2 + _count2);
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

String.prototype.count = function(c) {
  let result = 0;
  for(let i = 0; i < this.length; i++)
    if(this[i] == c)
      result++;
  return result;
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1);
}

function calc(s, c) {
  // console.log(s, c)
  if(s.length === 1)
    return s[0] !== c ? 1 : 0;

  const m = s.length / 2;
  const nxt = nextChar(c)
  let cntl = calc(s.substr(m), nxt);
  cntl += s.length / 2 - s.substr(0, m).count(c);
  let cntr = calc(s.substr(0, m), nxt);
  cntr += s.length / 2 - s.substr(m).count(c);
  return Math.min(cntl, cntr);
}

function main() {
  let t = readLine();
  t = parseInt(t);

  while(t--) {
    let n = parseInt(readLine());
    let s = readLine();
    console.log(calc(s, 'a'));
  }
}

var anum = 'a'.charCodeAt(0);
var mod = 'z'.charCodeAt(0) - anum + 1;

function next(x) {
   return (x + 1) % mod;
}

function solve() {
   var n = Number(read());
   var s = read();
   var arr = [];
   var cArr = [];
   for (var i = 0; i < mod; i++) {
      cArr.push([]);
   }
   for (var i = 0; i < n; i++) {
      arr.push(s.charCodeAt(i) - anum);
      for (var j = 0; j < mod; j++) {
         var x = arr[i] === j ? 1 : 0;
         if (i === 0) {
            cArr[j].push(x);
         } else {
            cArr[j].push(cArr[j][i - 1] + x);
         }
      }
   }
   write(f(0, n - 1, mod - 1)[1]);

   function count(l, r, c) {
      var res = cArr[c][r];
      if (l > 0) {
         res -= cArr[c][l - 1];
      }
      return res;
   }

   function f(l, r, c) {
      if (l === r) {
         if (arr[l] === c) {
            return [0, 1];
         }
         if (arr[l] === next(c)) {
            return [1, 0];
         }
         return [1, 1];
      }
      var m = (r + l) >> 1;
      var ansl = f(l, m, next(c));
      var ansr = f(m + 1, r, next(c));
      var countC = r - l + 1 - count(l, r, c);
      return [countC, Math.min(ansl[0] + ansr[1], ansl[1] + ansr[0])];
   }
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let lines = []
process.stdin.on('data', input => {
  lines = input.trim().split('\n')
})
process.stdin.on('end', main)

String.prototype.count=function(c) {
  var result = 0, i = 0;
  for(i;i<this.length;i++)if(this[i]==c)result++;
  return result;
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1);
}

function calc(s, c) {
  // console.log(s, c)
  if(s.length === 1)
    return s[0] !== c ? 1 : 0;

  const m = s.length / 2;
  const nxt = nextChar(c)
  let cntl = calc(s.substr(m), nxt);
  cntl += m - s.substr(0, m).count(c);
  let cntr = calc(s.substr(0, m), nxt);
  cntr += m - s.substr(m).count(c);
  return Math.min(cntl, cntr);
}

function main() {
  let t = lines[0]
  console.log(lines)

  for(let i = 2; i < lines.length; i += 2) {
    console.log(calc(lines[i], 'a'));
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let lines = []
process.stdin.on('data', input => {
  lines = input.trim().split('\n')
})
process.stdin.on('end', main)

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1);
}

function calc(s, c) {
  // console.log(s, c)
  if(s.length === 1)
    return s[0] !== c ? 1 : 0;

  const m = s.length / 2;
  const nxt = nextChar(c)
  let cntl = calc(s.substr(m), nxt);
  cntl += m - s.substr(0, m).split(c).length;
  let cntr = calc(s.substr(0, m), nxt);
  cntr += m - s.substr(m).split(c).length;
  return Math.min(cntl, cntr);
}

function main() {
  let t = lines[0]

  for(let i = 2; i < lines.length; i += 2) {
    console.log(calc(lines[i], 'a'));
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let lines = []
process.stdin.on('data', input => {
  lines = input.trim().split('\n')
})
process.stdin.on('end', main)

String.prototype.count=function(c) {
  var result = 0, i = 0;
  for(i;i<this.length;i++)if(this[i]==c)result++;
  return result;
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1);
}

function calc(s, c) {
  // console.log(s, c)
  if(s.length === 1)
    return s[0] !== c ? 1 : 0;

  const m = s.length / 2;
  const nxt = nextChar(c)
  let cntl = calc(s.substr(m), nxt);
  cntl += m - s.substr(0, m).count(c);
  let cntr = calc(s.substr(0, m), nxt);
  cntr += m - s.substr(m).count(c);
  return Math.min(cntl, cntr);
}

function main() {
  for(let i = 2; i < lines.length; i += 2) {
    console.log(calc(lines[i].trim(), 'a'));
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let lines = []
process.stdin.on('data', input => {
  lines = input.trim().split('\n')
})
process.stdin.on('end', main)

String.prototype.count=function(c) {
  var result = 0, i = 0;
  for(i;i<this.length;i++)if(this[i]==c)result++;
  return result;
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1);
}

function calc(s, c) {
  // console.log(s, c)
  if(s.length === 1)
    return s[0] !== c ? 1 : 0;

  const m = s.length / 2;
  const nxt = nextChar(c)
  let cntl = calc(s.substr(m), nxt);
  cntl += m - s.substr(0, m).count(c);
  let cntr = calc(s.substr(0, m), nxt);
  cntr += m - s.substr(m).count(c);
  return Math.min(cntl, cntr);
}

function main() {
  let t = lines[0]

  for(let i = 2; i < lines.length; i += 2) {
    console.log(calc(lines[i], 'a'));
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let lines = []
// process.stdin.on('data', input => {
//   lines = input.trim().split('\n').map(s => s.trim());
// })
// process.stdin.on('end', main)

String.prototype.count = function(c) {
  let result = 0;
  for(let i = 0; i < this.length; i++)
    if(this[i] == c)
      result++;
  return result;
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1);
}

function calc(s, c) {
  // console.log(s, c)
  if(s.length === 1)
    return s[0] !== c ? 1 : 0;

  const m = s.length / 2;
  const nxt = nextChar(c)
  let cntl = calc(s.substr(m), nxt);
  cntl += s.length / 2 - s.substr(0, m).count(c);
  let cntr = calc(s.substr(0, m), nxt);
  cntr += s.length / 2 - s.substr(m).count(c);
  return Math.min(cntl, cntr);
}

function prepareLines() {
  let t = parseInt(readline())
  for(let i = 0; i < t; i++) {
    lines.push(readline());
  }
}

function main() {
  prepareLines();
  for(let i = 1; i < lines.length; i += 2) {
    console.log(calc(lines[i].trim(), 'a'));
  }
}

// 'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let lines = []
process.stdin.on('data', input => {
  lines = input.trim().split('\n').map(s => s.trim());
})
process.stdin.on('end', main)

String.prototype.count = function(c) {
  let result = 0;
  for(let i = 0; i < this.length; i++)
    if(this[i] == c)
      result++;
  return result;
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1);
}

function calc(s, c) {
  // console.log(s, c)
  if(s.length === 1)
    return s[0] !== c ? 1 : 0;

  const m = s.length / 2;
  const nxt = nextChar(c)
  let cntl = calc(s.substr(m), nxt);
  cntl += s.length / 2 - s.substr(0, m).count(c);
  let cntr = calc(s.substr(0, m), nxt);
  cntr += s.length / 2 - s.substr(m).count(c);
  return Math.min(cntl, cntr);
}

function main() {
  for(let i = 2; i < lines.length; i += 2) {
    console.log(calc(lines[i].trim(), 'a'));
  }
}


According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check any person, i.e. learn his age and the drink he is having at the same time. What minimal number of people should Vasya check additionally to make sure that there are no clients under 18 having alcohol drinks?The list of all alcohol drinks in Berland is: ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE

The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does not contain spaces and other unnecessary separators. Only the drinks from the list given above should be considered alcohol.

Print a single number which is the number of people Vasya should check to guarantee the law enforcement.

NoteIn the sample test the second and fifth clients should be checked.

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var alcoholic = { "ABSINTH": true, "BEER": true, "BRANDY": true,
		"CHAMPAGNE": true, "GIN": true, "RUM": true, "SAKE": true,
		"TEQUILA": true, "VODKA": true, "WHISKEY": true, "WINE": true },
		numPatrons = parseInt(readline(), 10),
		numChecks = 0,
		agePattern = /\d+/;
	for (var patronIx = 0; patronIx < numPatrons; ++patronIx) {
		var token = readline().replace(/\s+/g, "");
		if (agePattern.test(token)) {
			if (parseInt(token, 10) < 18) {
				++numChecks;
			}
		}
		else if (alcoholic[token] != undefined) {
			++numChecks;
		}
	}
	print(numChecks);
}

main();

'use strict'

let lll
let N = +readline()
const alc = ['ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE']
let ch = 0

while (lll = readline()) {
  if (+lll == lll) {
    if (lll < 18) ch++
  } else {
    if (~alc.indexOf(lll)) ch++
  }
}

print(ch)

'use strict';

// let inpFileStrArr = `
// 5
// 18
// VODKA
// COKE
// 19
// 17
// `.trim().split('\n'), inpFileCounter = 0;
// function readline() {
//   return inpFileStrArr[inpFileCounter++];
// }
// function print(x) {
//   console.log(x);
// }

var alcohol = ['ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE'];

var n = Number(readline()),
    count = 0;
for (var i = 0; i < n; i++) {
  var str = readline();
  if (isNaN(str) && alcohol.indexOf(str) === -1 || !isNaN(str) && Number(str) >= 18) {
    continue;
  }
  count++;
}

print(count);

'use strict';

/*let input = `2
2
GIN`.split('\n');
function print(out) {
    console.log(out);
}
function readline() {
    return input.shift();
}*/

//code

var n = Number(readline());
var drinks = ["ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"];
var count = 0;
for (var i = 0; i < n; i++) {
    var line = readline();
    if (!isNaN(Number(line))) {
        if (Number(line) < 18) {
            count++;
        }
    } else if (drinks.includes(line)) {
        count++;
    }
}
print(count);

var alco = ['ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE'];
var n = parseInt(readline());
var res = 0;

while(n--) {
	var input = readline();
	var num = parseInt(input);
	if (num >= 0) {
		if (num < 18) {
			res++;
		}
	} else {
		if (alco.indexOf(input) !== -1) {
			res++;
		}
	}
}

print(res);

var arr = ["ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"];
var t = Number(readline());
var ans = 0;
while(t--) {
    var input = readline();
    if ((input[0] >= "0" && input[0] <= "9" && input < 18) || arr.includes(input))
        ++ans;
}
print(ans);

'use strict';

/*let input = `5
18
VODKA
COKE
19
17`.split('\n');
function print(out) {
    console.log(out);
}
function readline() {
    return input.shift();
}*/

//code

var n = Number(readline());
var drinks = ["ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"];
var count = 0;
for (var i = 0; i < n; i++) {
    var line = readline();
    if (!isNaN(Number(line))) {
        if (Number(line) < 18) {
            count++;
        }
    } else if (!drinks.includes(line)) {
        count++;
    }
}
print(count);

var alco = ['ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE'];
var n = parseInt(readline());
var res = 0;

while(n--) {
	var input = readline();
	if (num = parseInt(input)) {
		if (num < 18) {
			res++;
		}
	} else {
		if (alco.indexOf(input) !== -1) {
			res++;
		}
	}
}

print(res);

var arr = ["ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"];
var t = Number(readline());
var ans = 0;
while(t--) {
    var input = readline();
    if ((typeof input == 'number' && input < 18))
        ++ans;
}
print(ans);

var arr = ["ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"];
var t = Number(readline());
var ans = 0;
while (t--) {
    var input = readline();
    if ((typeof input === 'number' && input < 18) || arr.includes(input))
        ++ans;
}
print(ans);

var arr = ["ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"];
var t = Number(readline());
var ans = 0;
while(t--) {
    var input = readline();
    if ((input[0] >= "0" && input[0] <= "9") || arr.includes(input))
        ++ans;
}
print(ans);

var arr = ["ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"];
var t = Number(readline());
var ans = 0;
while(t--) {
    var input = readline();
    if ((typeof input == 'number' && input < 18) || arr.includes(input))
        ++ans;
}
print(ans);