const readline = require('readline');
const { stdin: input, stdout: output } = require('process')
const rl = readline.createInterface({ input, output })

let lines = []

const createReadLine = () => {
  i = 0;
  return () => lines[i++]
}
const int = (num, radix=10) => parseInt(num, radix)

const countPower = (num) => {
  let pow = 0
  while (!(num & 1)) {
    num >>= 1;
    pow++;
  }
  return pow
}

rl.on('line', line => lines.push(line))

rl.on("close", () => {
  const readLine = createReadLine();
  let t = int(readLine());
  // let t = 1;
  while (t--) {
    const n = int(readLine());
    const arr = readLine().split(' ').map(a => int(a));

    let pow = 0;
    for (let i = 0; i < n; i++) {
      pow += countPower(arr[i]);
    }
    let ans = 0;
    if (pow < n) {
      let powArr = [];
      for (let i = 1; i <= n; i++) {
        powArr.push(countPower(i));
      }
      powArr.sort((a, b) => b - a);

      for (let i = 0; i < n; i++) {
        pow += powArr[i]
        ans++;
        if (pow >= n) break;
      }
    }

    console.log((pow >= n) ? ans : -1);
  }
});

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    let k = 0
    const ps = Array(n)
    for (let i = 0; i < arr.length; i++) {
        let x = arr[i]
        while (!(x & 1)) {
            x /= 2
            k++
        }
        //
        x = i + 1
        ps[i] = 0
        while (!(x & 1)) {
            x /= 2
            ps[i]++
        }
    }
    ps.sort((a, b) => a - b)
// console.log(k, ps)
    let i = n - 1
    let r = 0
    while (k < n && i >= 0 && ps[i] > 0) {
        const x = ps[i]
        // if (x) {
            k += x
            r++
        // }
        i--
    }
    if (k < n) return -1
    return r
}

const lines = [];
const _rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
_rl.on('line', line => lines.push(line));
_rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);
const rl = readline;

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const sumab = (a, b) => {
    if (a > b) return 0;
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return x * y;
}

let fact2 = (a) => {
    let cnt = 0;
    while (a % 2 === 0) {
        cnt++;
        a /= 2;
    }
    return cnt;
}

const NN = 200005;
let twos = new Array(NN).fill(0);
for (let i = 0; i < NN; i++) {
    twos[i] = fact2(i + 1);
}

const calc = (t)=>{
    /* read */
    let n = +rl();
    let a = ra();

    let sum2 = 0;
    let potential2 = [];
    let potentialsum = 0;
    let moves = 0;
    for (let i = 0; i < n; i++) {
        if (a[i] < NN) {
            sum2 += twos[a[i] - 1];
        } else {
            sum2 += fact2(a[i]);
        }
        potential2.push(twos[i]);
        potentialsum += twos[i];
    }
    if (sum2 >= n) return 0;
    if (sum2 + potentialsum < n) return -1;

    potential2.sort((a, b) => b - a);
    let cursum = 0;
    for (let i = 0; i < n; i++) {
        cursum += potential2[i];
        if (sum2 + cursum >= n) return i + 1;
    }
    return -1;
};

function main() {
    let T = +readline();
    let out = [];
    for (let t = 1; t <= T; t++){
        // calc(t);
        out.push(calc(t));
        // process.stdout.write(`${calc(t)}\n`);
    }
    process.stdout.write(out.join('\n')+'\n');
}

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    let z=0;
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[++z]);
        let a=line[++z].split(' ').map(x=>{return parseInt(x)});
        let ans=0;
        let cnt=0;
        for(let i=0;i<n;i++)
        {
            let x=a[i];
            while(x%2==0)
            {
                x/=2;
                cnt++;
            }
        }
        if(cnt>=n) console.log(0);
        else
        {
            let b=[];
            for(let i=1;i<=n;i++)
            {
                let c=0;
                let x=i;
                while(x%2==0)
                {
                    x/=2;
                    c++;
                }
                b.push(c);
            }
            b.sort(function(a,b){
                return b-a;
            })
            for(let i=0;i<n;i++) {
                cnt+=b[i];
                ans++;
                if(cnt>=n) break;
            }
            if(cnt>=n) console.log(ans);
            else console.log(-1);
        }
    }
})

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};

const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let k = n;
    for (let i = 0; i < n; i++) {
      while (arr[i] % 2 === 0) {
        k--;
        arr[i] = arr[i] / 2;
      }
    }
    if (k <= 0) console.log(0);
    else {
      const helper = () => {
        let j = [];
        for (let i = 1; i <= n; i++) {
          if (i % 2 === 0) {
            if (Math.log2(i) % 1 === 0) j.push(Math.log2(i));
            else {
              let cnt = 0,
                l = i;
              while (l % 2 === 0) {
                cnt++;
                l = l / 2;
              }
              j.push(cnt);
            }
          }
        }
        j.sort((a, b) => b - a);
        for (let i = 0; i < j.length; i++) {
          k = k - j[i];
          if (k <= 0) return i + 1;
        }
        return -1;
      };
      console.log(helper());
    }
  }
};
solve();

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns();
  let t = n;
  for (let i = 0; i < n; i++) {
    let ans = 0,
        num = a[i];
    while (num % 2 === 0) {
      ans++;
      num /= 2;
    }
    t -= ans;
  }
  if (t <= 0) return 0;
  let nums = [];
  for (let i = n; i; i--) {
    let ans = 0,
        num = i;
    while (num % 2 === 0) {
      ans++;
      num /= 2;
    }
    if (ans) nums.push(ans);
  }
  nums.sort((a, b) => b - a);
  for (let i = 0; i < n; i++) {
    t -= nums[i];
    if (t <= 0) return i + 1;
  }
  return -1;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    let k = 0
    for (let i = 0; i < arr.length; i++) {
        let x = arr[i]
        while (!(x & 1)) {
            x /= 2
            k++
        }
    }
    let m = Math.floor(Math.log2(n))
    let r = 0
    while (k < n && m > 0) {
        k += m--
        r++
    }
    if (k < n) return -1
    return r
}


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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

const mxN = 1e5+5;
const sum = Array(mxN).fill(0);
const cnt = Array(mxN).fill(0);
const pos = Array(mxN).fill(0);

function main () {
	const [n, m] = rna();
	const a = [];
	for (let i = 0; i < n; i++) a[i] = rna();

	let ans = 0;
	for (let i = 0; i < n; i++) {
		for (let j = 0; j < m; j++) {
			const curCol = a[i][j];
			sum[curCol] += cnt[curCol] * (i - pos[curCol]);
			cnt[curCol]++;
			pos[curCol] = i;
			ans += sum[curCol];
		}
	}

	for (let i = 0; i < mxN; i++) sum[i] = cnt[i] = pos[i] = 0;

	for (let j = 0; j < m; j++) {
		for (let i = 0; i < n; i++) {
			const curCol = a[i][j];
			sum[curCol] += cnt[curCol] * (j - pos[curCol]);
			cnt[curCol]++;
			pos[curCol] = j;
			ans += sum[curCol];
		}
	}

	console.log(ans);
}

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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

const mxN = 1e5 + 5;
const mxP = 1e5 + 5;
const pos = Array.from(Array(2 * mxP), x => []);

function main () {
	const [n, m] = rna();

	for (let i = 0; i < n; i++) {
		for (const [j, c] of rna().entries()) {
			pos[2 * c + 0].push(i);
			pos[2 * c + 1].push(j);
		}
	}

	let ans = 0;
	for (const v of pos) {
		v.sort((x, y) => x - y);
		for (let i = 0, sum = 0; i < v.length - 1; i++) {
			sum += (i + 1) * (v[i + 1] - v[i]);
			ans += sum;
		}
	}

	console.log(ans);
}


print(function(n, k) {
	var ans = [];

	for (var i = 1, c = 0; i <= n * 2; i += 2, c++) {
		if (c < k) {
			ans.push(i + 1);
			ans.push(i);
		} else {
			ans.push(i);
			ans.push(i + 1);
		}
	}

	return ans.join(' ');

}.apply(0, readline().split(' ').map(Number)));

print(function(n, k) {
	var i, ans = [];
	for (i = 1; i <= n * 2; i++) {
		ans.push(i);
	}

	if (k > 0) {
		ans[0] = k + 1;
		ans[1] = 1;
		if (k > 1) {
			if ((k + 1) % 2) {
				ans[k] = 2;
			} else {
				ans[k] = ans[k - 1];
				ans[k - 1] = 2;
			}
		}
	}

	return ans.join(' ');

}.apply(0, readline().split(' ').map(Number)));

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]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var n = integers[0], k = integers[1];
	var m = 2*n;
	var perm = [];
	for (var i = 1; i <= k; ++i) {
		perm.push(2*i);
		perm.push(2*i-1);
	}
	for ( ; i <= n; ++i) {
		perm.push(2*i-1);
		perm.push(2*i);
	}
	print(perm.join(" "));
}

main();