var tc = parseInt(readline())
while(tc--) {
    var n = readline();
    var arr = readline().split(" ").map(i => Number(i));
    var ans = 0;
    // for(var i = 1; i < arr.length; i++) {
    //     if (i) {
    //         var min = Math.min(arr[i], arr[i-1]);
    //         var max = Math.max(arr[i], arr[i-1]);
    //         while (true) {
    //             if (min * 2 >= max) {
    //                 break;
    //             }
    //             min *= 2;
    //             ++ans;
    //         }
    //     }
    // }
    arr.forEach((val, i) => {
        if (i) {
            var min = Math.min(arr[i], arr[i-1]);
            var max = Math.max(arr[i], arr[i-1]);
            while (true) {
                if (min * 2 >= max) {
                    break;
                }
                min *= 2;
                ++ans;
            }
        }
    });
    print(ans)
}

let lines = require('fs').readFileSync(0).toString().split('\n');
let index = 0;
const readline = () => lines[index++];

let t = Number(readline());
for(let i = 0; i < t; i++) {
    readline();
    let arr = readline().split(' ').map(i=> +i);
    let result = 0;
    for(let j = 1; j < arr.length; j++) {
        let min = arr[j];
        let max = arr[j - 1];
        if (max < min) [min, max] = [max, min]
        while(min * 2 < max) {
            min *= 2
            result++
        }
    }
    console.log(result)
}

let {stdin} = process

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

let string = '';
let line = 0;

stdin.on('data', input => string += input);
stdin.on('end', () => {
    string = string.trim().split('\n').map(string => string.trim());
    main();
});

const readline = () => string[line++];

function main(){
 let t = Number(readline());
 for(let i = 0; i < t; i++) {
     readline();
     let arr = readline().split(' ').map(i=> +i);
     let result = 0;
     for(let j = 1; j < arr.length; j++) {
         let min = arr[j];
         let max = arr[j - 1];
         if (max < min) [min, max] = [max, min]
         while(min * 2 < max) {
             min *= 2
             result++
         }
     }
     console.log(result)
 }
}

let {stdin} = process

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

let string = '';
let line = 0;

stdin.on('data', input => string += input);
stdin.on('end', () => {
    string = string.trim().split('\n').map(string => string.trim());
    main();
});

const readline = () => string[line++];

function main(){
 let t = Number(readline());
 for(let i = 0; i < t; i++) {
     readline();
     let arr = readline().split(' ').map(i=> +i);
     let result = 0;
     for(let j = 1; j < arr.length; j++) {
         let min = arr[j];
         let max = arr[j - 1];
         if (max < min) [min, max] = [max, min]
         while(min * 2 < max) {
             min *= 2
             result++
         }
     }
     console.log(result)
 }
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
 var a = parseInt(readline());
while (a--) {
   var ok =parseInt(readline());
   var arr = readline().split(" ")
   var c = 0;

   for (let i = 0; i < arr.length - 1; i++) {
      var max=Math.max(arr[i],arr[i+1])
     var min=Math.min(arr[i],arr[i+1]);
     while(min*2<max){
      //  console.log(a[i],min,max);
        min=min*2
        c++;
     }

   }

   console.log(c)

   // var [a,b,c] = readline().split(" ").map(Number);
   // var arr=new Array();
   // var num=1,ans;
   // for(let i=0;i<a;i++){
   //    arr[i]=new Array()
   //    for(let j=0;j<b;j++){
   //    arr[i][j]=num;
   //    if(num==c)
   //    ans=c
   //    num++;
   //    }
   // }
   // console.log(arr);
}

}

const solutionA = (inputs) => {
  // helper
  const getAns = (elements, array) => {
    let ans = 0;
    for (let i = 1; i < elements; i++) {
      const [ge, le] = array[i - 1] > array[i] ? [i - 1, i] : [i, i - 1];
      if (array[ge] / array[le] <= 2) continue;
      for (let j = array[le] * 2; j < array[ge]; j *= 2) {
        ans += 1;
      }
    }
    return ans;
  };

  const [, ...rest] = inputs;
  const q = rest.length;
  const ans = [];
  for (let i = 0; i < q; i += 2) {
    const elements = +rest[i];
    const array = rest[i + 1].split(" ").map((e) => Number(e));
    ans.push(getAns(elements, array));
  }
  console.log(ans.join("\n"));
};

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

const q = [];
rl.on("line", (line) => {
  line
    ? q.push(line)
    : rl.close();
}).on("close", () => {
  solutionA(q);
  process.exit();
});

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);
            var ans = 0;
            for(j = 0; j < e - 1; j++){
                var min = Math.min(k[j], k[j + 1]);
                var max = Math.max(k[j], k[j + 1]);
                while(max / min > 2){
                    max = Math.ceil(max / 2);
                    ans++;
                }
            }
            console.log(ans);
        }
    }
});

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function find(num1, num2){
    if(num1 < num2){
        let temp = num2;
        num2 = num1;
        num1 = temp;
    }
    let count = 0;
    for (let i = 0; num1 > num2; i++) {
        num1 = num1 / 2;
        count++;
    }
    return count - 1;
}

function main(input){
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let length = +input[z++];
        let arr = input[z++].split(' ').map(x=>Number(x));
        let swap = 0;
        for (let i = 0; i < length - 1; i++) {
            if(arr[i]*2 < arr[i+1] || arr[i] / 2 > arr[i+1]){
                swap = swap + find(arr[i], arr[i+1]);
            }
        }
        console.log(swap);
    }
}

'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++];
}

// Actual code...

function numBetween(a, b) {
    const small = Math.min(a, b);
    const big = Math.max(a, b);
    if (big / small > 2) return 1 + numBetween(small * 2, big);
    return 0;
}

function main() {
    const numCases = parseInt(readline());
    for (let i = 0; i < numCases; i++) {
        const numTerms = readline();
        const arr = readline()
            .split(" ")
            .map(str => parseInt(str));
        let numNeeded = 0;
        for (let j = 0; j < numTerms - 1; j++) {
            numNeeded += numBetween(arr[j], arr[j + 1]);
        }
        console.log(numNeeded);
    }
}

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 = () => {
	let t = nl.num();
    let ans = [];
    for(let i = 0; i < t; i++) {
        let n = nl.num();
        let a = nl.nums();
        let cnt = 0;
        for(let j = 0; j < n - 1; j++){
            let x = a[j];
            let y = a[j + 1];
            if (x > y) {
                [x, y] = [y, x];
            }
            while(x * 2 < y) {
                cnt++;
                x *= 2;
            }
        }
        ans.push(cnt);
    }
	console.log(ans.join('\n'));

};

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

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

let input = [];

rl.on("line", (ln) => {
  input.push(ln);
}).on("close", () => {
  const T = input.shift();

  for (let i = 0; i < T; i++) {
    const N = input.shift();
    const nums = input.shift().split(" ");

    let sum = 0;
    for (let j = 0; j < N - 1; j++) {
      const min = Math.min(nums[j], nums[j + 1]);
      const max = Math.max(nums[j], nums[j + 1]);
      const div = max / min;

      let times = Math.log(div) / Math.log(2);
      times = times % 1 === 0 && times > 0 ? times - 1 : Math.floor(times);
      sum += times;
    }
    console.log(sum);
  }
});

/**
 * 02/19/21 morning
 * https://codeforces.com/contest/1490/problem/A
 */

///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
///////////////////////////////////////////////////////////////////////////////////

const solve = (n, a) => {
    let res = 0;
    for (let i = 0; i + 1 < n; i++) {
        let min = mi(a[i], a[i + 1]);
        let max = mx(a[i], a[i + 1]);
        while (max > min && max / min > 2) {
            max = Math.ceil(max / 2);
            res++;
        }
    }
    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()

let fs = require("fs");
let allInput = fs.readFileSync(0).toString(); // STDIN_FILENO = 0
let allLines=allInput.split('\n');
let line=0;
const T=parseInt(allLines[line++]);
function count(a, b) {
    let c=0;
    while (a*2<b) {
        a*=2;
        c++;
    }
    while (b*2<a) {
        b*=2;
        c++;
    }
    return c;
}

for (let tt=0; tt<T; tt++) {
    const n=parseInt(allLines[line++]);
    const a=allLines[line++].split(" ").map(Number);
    let add=0;
    for (let ind=0; ind+1<n; ind++) {
        add+=count(a[ind], a[ind+1]);
    }
    console.log(add);
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        solve()
        process.exit(0)
    }
})

function diff(max, min) {
    let res = 0
    while (max > min) {
        if ((Math.ceil(max / min)) > 2) {
            res++
            if (max % 2 === 0) max /=2
            else max = Math.floor(max / 2) + 1
        } else {
            return res
        }
    }
    return res
}

function isDense(arr) {
    let counter = 0
    for (let i = 0; i < arr.length - 1; i++) {
        if (arr[i] >= arr[i + 1]) {
            if (arr[i] / arr[i + 1] > 2) counter += diff(arr[i], arr[i + 1])
        } else {
            if (arr[i + 1] / arr[i] > 2) counter += diff(arr[i + 1], arr[i])
        }
    }
    console.log(counter)
}

function solve() {
    for (let i = 1; i < inputArr.length; i += 2) {
        isDense(inputArr[i])
    }
}

/*
 * File Created: Tuesday, 16th February 2021 3:32:09 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 = parseInt(readLine());

        const arr = readLine().split(' ').map(Number);

        const res = a(n,arr);

        console.log(res)
     }
 });

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

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

 function a(n,arr){
     let count = 0;
     for(let i = 0 ; i < n - 1; i++){
         let max = Math.max(arr[i], arr[i+1]);
         let min = Math.min(arr[i], arr[i+1]);
         if(max/min > 2){
             while(min * 2 < max){
                 max = max / 2;
                 count++;
             }
         } else{
             continue;
         }
     }
     return count;
 }

 module.exports = a;

'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++];
}
/**
2
3 7
24 25 27
10 7
51 52 53 54 55 56 57 58 59 60
**/

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

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = readline();
    let a = readline().split(" ").map(Number);

    let count = 0;
    //console.log(a);
    for(let i=0;i<a.length - 1;i++) {
        let max = Math.max(a[i], a[i+1]);
        let min = Math.min(a[i], a[i+1]);
        //console.log(max / min)
        while((max / min) > 2) {
            max = Math.ceil(max / 2);
            count++;
        }
    }

    console.log(count);

}

'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 = Number(readline())

        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        var res = 0
        for (var i = 0; i < a.length - 1; i++) {
            var min = Math.min(a[i + 1], a[i])
            var max = Math.max(a[i + 1], a[i])
            while (min*2 < max){
                min *=2
                res++
            }
            // console.log(res)
        }
        console.log(res)

    })

}

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

    return gcd(b, a % b);
}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var output = 0;
		for(var j = 0; j < N - 1; j++){
			var max = Math.max(list[j], list[j + 1]);
			var min = Math.min(list[j], list[j + 1]);
			while(max > min * 2){
				min *= 2;
				output++;
			}
		}
		myout(output);
	}
}

var tc = parseInt(readline());
while(tc--) {
    var n = readline();
    var arr = readline().split(" ").map(i => Number(i));
    var ans = 0;
    arr.forEach((value, index) => {
        if (index) {
            var min = Math.min(arr[index], arr[index-1]);
            var max = Math.max(arr[index], arr[index-1]);
            while (true) {
                if (min * 2 >= max) break;
                min *= 2;
                ++ans;
            }
        }
    });
    print(ans);
}

var tc = parseInt(readline())
while(tc--) {
    var n = readline();
    var arr = readline().split(" ").map(i => Number(i));
    var ans = 0;
    for(var i = 1; i < arr.length; i++) {
        if (i) {
            var min = Math.min(arr[i], arr[i-1]);
            var max = Math.max(arr[i], arr[i-1]);
            while (true) {
                if (min * 2 >= max) {
                    break;
                }
                min *= 2;
                ++ans;
            }
        }
    }
    print(ans)
}

var tc = parseInt(readline())
while(tc--) {
    var n = readline();
    var arr = readline().split(" ").map(i => Number(i));
    var ans = 0;
    for(var i = 1; i < arr.length; i++) {
        if (i) {
            var min = Math.min(arr[i], arr[i-1]);
            var max = Math.max(arr[i], arr[i-1]);
            while (true) {
                if (min * 2 >= max) {
                    break;
                }
                min *= 2;
                ++ans;
            }
        }
    }
    // write(ans + '\n')
    print(ans)
}

var tc = parseInt(readline())
while(tc--) {
    var n = readline();
    var arr = readline().split(" ").map(i => Number(i));
    var ans = 0;
    for(var i = 1; i < arr.length; i++) {
        if (i) {
            var min = Math.min(arr[i], arr[i-1]);
            var max = Math.max(arr[i], arr[i-1]);
            while (true) {
                if (min * 2 >= max) {
                    break;
                }
                min *= 2;
                ++ans;
            }
        }
    }
    write(ans + '\n')
}

var tc = parseInt(readline())
for(var t = 1; t <= tc; t++) {
    var n = readline();
    var arr = readline().split(" ").map(i => Number(i));
    var ans = 0;
    for(var i = 1; i < arr.length; i++) {
        if (i) {
            var min = Math.min(arr[i], arr[i-1]);
            var max = Math.max(arr[i], arr[i-1]);
            while (true) {
                if (min * 2 >= max) {
                    break;
                }
                min *= 2;
                ++ans;
            }
        }
    }
    write(ans + '\n')
}

var tc = parseInt(readline())
for(var i = 1; i <= tc; i++) {
    var n = readline();
    var arr = readline().split(" ").map(i => Number(i));
    var result = 0;
    for(var j = 1; j < arr.length; j++) {
        var now = arr[j];
        var before = arr[j-1]
        if (now > before) {

        while (now > before * 2) {
            before *= 2
            result++
        }
        } else if (before > now * 2) {
            while (before > now * 2) {
                now *= 2
                result++
            }
        }
    }
    write(result + '\n')
}

var tc = parseInt(readline())
for(var i = 1; i <= tc; i++) {
    var n = readline();
    var arr = readline().split(' ').map(i => Number(i));
    var result = 0;
    for(var j = 1; j < arr.length; j++) {
        var now = arr[j];
        var before = arr[j-1]
        if (now > before) {

        while (now > before * 2) {
            before *= 2
            result++
        }
        } else if (before > now * 2) {
            while (before > now * 2) {
                now *= 2
                result++
            }
        }
    }
    write(result + '\n')
}

var num = parseInt(readline())
for(var i = 0; i < num; i++) {
    readline();
    var arr = readline().split(' ').map(i => Number(i));
    var result = 0;
    for(var j = 1; j < arr.length; j++) {
        var now = arr[j];
        var before = arr[j-1]
        if (now > before) {

        while (now > before * 2) {
            before *= 2
            result++
        }
        } else if (before > now * 2) {
            while (before > now * 2) {
                now *= 2
                result++
            }
        }
    }
    write(result + '\n')
}

var num = readline() * 1
for(var i = 0; i < num; i++) {
    readline();
    var arr = readline().split(' ').map(i => Number(i));
    var result = 0;
    for(var j = 1; j < arr.length; j++) {
        var now = arr[j];
        var before = arr[j-1]
        if (now > before) {

        while (now > before * 2) {
            before *= 2
            result++
        }
        } else if (before > now * 2) {
            while (before > now * 2) {
                now *= 2
                result++
            }
        }
    }
    write(result + '\n')
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
var n = row[0]; //input

for(var times = 0; times < n; times++) {
    var l = readline().split(" ").map(function(x) { return parseInt(x); })[0];
    var a = readline().split(" ").map(function(x) { return parseInt(x); });
    var result = 0;
    for(var i = 1; i < l; i++) {
        var previous = a[i - 1];
        var current = a[i];
        var max = Math.max(previous, current);
        var min = Math.min(previous, current);
        while(max / min > 2) {
            result++;
            var halfMax = Math.ceil(max / 2);
            max = Math.max(halfMax, min);
            min = Math.min(halfMax, min);
        }
    }
    write(result + "\n" );
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
var n = row[0]; //input

for(var times = 0; times < n; times++) {
    var l = readline().split(" ").map(function(x) { return parseInt(x); })[0];
    var a = readline().split(" ").map(function(x) { return parseInt(x); });
    var result = 0;
    for(var i = 1; i < l; i++) {
        var previous = a[i - 1];
        var current = a[i];
        var max = Math.max(previous, current);
        var min = Math.min(previous, current);
        while(max / min > 2) {
            result++;
            var halfMax = Math.ceil(max / 2);
            max = Math.max(halfMax, min);
            min = Math.min(halfMax, min);
        }
    }
    write(result + "\n");
}

var t = Number(readline());

while (t--) {
    var len = Number(readline());
    var arr = readline().split(" ");
    var ans = 0;

    for (var i = 0; i < len - 1; i++) {
        var a = Number(arr[i]);
        var b = Number(arr[i + 1]);
        var min = Math.min(a, b);

        while (min * 2 < Math.max(a, b)) {
            ans++;
            min *= 2;
        }

    }

    print(ans);
}

var t=parseInt(readline(), 10);
for (var i=0; i<t; i++) {
    var n=parseInt(readline(), 10);
    var w=readline().split(" ");
    var res=0;
    for (var j=1; j<n; j++) {
        var a=parseInt(w[j], 10);
        var b=parseInt(w[j-1], 10);
        var y=Math.log2(Math.max(a, b)/Math.min(a, b));
        if (y==Math.floor(y)&&y!=0) {
            y-=1;
        }
        res+=Math.floor(y);
    }
    print(res);
}

var Case = parseInt( readline() );
while(Case--){
  var n = readline();
  var A = readline().split(' ').map(i => Number(i));
  var Ans = 0;
  A.forEach((val,index) =>{
     if(index){
        var min = Math.min(A[index], A[index-1]);
        var max = Math.max(A[index], A[index-1]);
        while (min*2 < max) {
            min *= 2;
            Ans++;
        }
     }
  });
  print(Ans);
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
  // your code goes here
  var a = readline();
while (a--) {
   var arr = readline().split(" ")
   var c = 0;

   for (let i = 0; i < arr.length - 1; i++) {
      var max=Math.max(arr[i],arr[i+1])
     var min=Math.min(arr[i],arr[i+1]);
     while(min*2<max){
      //  console.log(a[i],min,max);
        min=min*2
        c++;
     }

   }

   console.log(c)

   // var [a,b,c] = readline().split(" ").map(Number);
   // var arr=new Array();
   // var num=1,ans;
   // for(let i=0;i<a;i++){
   //    arr[i]=new Array()
   //    for(let j=0;j<b;j++){
   //    arr[i][j]=num;
   //    if(num==c)
   //    ans=c
   //    num++;
   //    }
   // }
   // console.log(arr);
}

}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
var n = row[0]; //input

for(var times = 0; times < n; times++) {
    var l = readline().split(" ").map(function(x) { return parseInt(x); })[0];
    var a = readline().split(" ").map(function(x) { return parseInt(x); });
    var result = 0;
    var current = [0,0];
    current[-1] = 0;
    var max = 0;
    var currentMax = 0;
    for(var i = 0; i < l; i++) {
        var currentIdx = a[i] % 3 == 2? -1 : a[i] % 3;
        current[currentIdx]++;
        if(current[currentIdx] > max || (current[currentIdx] == max && currentIdx < currentMax)) {
            max = current[currentIdx];
            currentMax = currentIdx;
        }
    }
    var equal = l / 3;
    var holding = 0;
    for(var times2 = 1; times2 < 3; times2++) {
        holding = current[currentMax] + holding - equal;
        result += holding;
        currentMax = currentMax + 1 > 1 ? -1 : currentMax + 1;
    }
    write(result + "\n");
}


process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 === 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = numArray(rl());
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let len1 = arr.filter((a) => a == 1).length;
    let len2 = arr.filter((a) => a == 2).length;

    let ar1 = isEven(len1);
    let ar2 = isEven(len2);

    if (len1 == 0 && ar2) cl("Yes");
    else if (ar1 && len2 == 0) cl("Yes");
    else if (ar1 && ar2) cl("Yes");
    else if (ar1 && !ar2) cl("Yes");
    else cl("No");
  }
}

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 n = lines[i].split(' ').map(Number);
            var div = 0, sum = 0, one = 0;
            for(j = 0; j < e; j++){
                if(n[j] == 1){
                    one++;
                    sum++;
                }else{
                    sum += 2;
                }
            }
            if(sum % 2 === 0){
                div = Math.floor(sum / 2);
                if(div % 2 === 0){
                    console.log('YES');
                }else{
                    if(one % 2 === 0 && one !== 0){
                        console.log('YES');
                    }else{
                        console.log('NO');
                    }
                }
            }else{
                console.log('NO');
            }
        }
    }
});

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 n = lines[i].split(' ').map(Number);
            var div = 0, sum = 0, one = 0;
            for(j = 0; j < e; j++){
                if(n[j] == 1){
                    one++;
                    sum++;
                }else{
                    sum += 2;
                }
            }
            if(sum % 2 === 0){
                div = Math.floor(sum / 2);
                if(div % 2 === 0){
                    console.log('YES');
                }else{
                    if(one){
                        console.log('YES');
                    }else{
                        console.log('NO');
                    }
                }
            }else{
                console.log('NO');
            }
        }
    }
});

'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() {
  let t = Number(readline());
  while (t--) {
    const n = Number(readline());
    let sum = 0;
    let candies = readline().split(' ').map(Number);
    let ones = 0;
    for (let c of candies) {
      sum += c;
      if (c === 1) ones++;
    }
    if (sum % 2 === 0) {
      if (ones === 0 && n % 2 !== 0) console.log('NO');
      else console.log('YES');
    } else {
      console.log('NO');
    }
  }
}

const { Console } = require("console");
const { RSA_X931_PADDING } = require("constants");
const { maxHeaderSize } = require("http");
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const array = input.slice(1).map(val => val.split(" ").map(v => Number(v)));
    let n = 0;

    for(let idx in array) {
        if(idx % 2 === 0) n = array[idx];
        else {
            let cnt1 = 0, cnt2 = 0;
            const one = array[idx].join("").match(/1/g);
            const two = array[idx].join("").match(/2/g);

            if(one !== null) cnt1 = one.length;
            if(two !== null) cnt2 = two.length;

            const sum = cnt1 + 2 * cnt2;

            if(sum % 2 !== 0) {
                console.log("NO");
            } else {
                if(cnt1 === 0) {
                    if(cnt2 % 2 === 0) console.log("YES");
                    else console.log("NO");
                } else if(cnt1 % 2 === 0 && cnt2 % 2 === 0) console.log("YES");
                else {
                    if(cnt1 % 2 === 0 && cnt2 % 2 !== 0) console.log("YES");
                    else {
                        if(cnt1 % 2 !== 0) console.log("NO");
                        else console.log("YES")
                    }
                }
            }
        }
    }
}

function sum(arr) {
    let res = 0;
    for (let a of arr) {
        res += a;
    }
    return res;
}

const countObj = (arr, val)  => arr.reduce((a, v) => (v == val ? a + 1 : a), 0);

function solve(input) {
    // YOUR BUGS HERE...
    let res = [];
    for (let el of input) {
        let ans = 'NO'
        let a = el[1].split(' ').map(i => parseInt(i));
        const sumA = eval(a.join('+'))
        if (sumA % 2 !== 0) {
            ans = 'NO'
        } else {
            const halfSum = sumA / 2;
            if (halfSum === 1 && a[0] === 1) {
                ans = 'YES';
            } else if (halfSum % 2 === 0) {
                ans = countObj(a, 2) >= (halfSum / 2) || countObj(a, 1) >= halfSum ? 'YES' : 'NO';
            } else if (halfSum % 2 !== 0) {
                ans = (countObj(a, 2) >= ((halfSum - 1) / 2) && countObj(a, 1) >= 1) || countObj(a, 1) >= halfSum ? 'YES' : 'NO'
            }
        }
        res.push(ans)
    };
    console.log(res.join('\n'));
}

/** =========== DEFAULT FORMAT ==============
 *
 * use this format to solve problem that use more than 1 inputs per testcase
 *
 *  */
function set_n_line() {
    // set return 0 if the problem needs dynamic n line inputs
    // set return n > 0 if the problem needs fixed n  line inputs
    return 2
}
const readline = require('readline').createInterface({ input: process.stdin });
let inputs = []; let sub_input = []; let t = 0; let n_line_subinput = set_n_line();
function fillInput(line) {
    // dynamic n_line
    if (n_line_subinput == 0) n_line_subinput = parseInt(line)
    else if (sub_input.length < n_line_subinput) {
        sub_input.push(line)
        if (sub_input.length == n_line_subinput) {
            inputs.push(sub_input); sub_input = [];
            n_line_subinput = set_n_line();
        }
    }
}

readline.on('line', line => {
    if (t == 0) t = parseInt(line)
    else if (inputs.length < t) {
        fillInput(line)
        if (inputs.length == t) { solve(inputs);readline.close() }
    }
});
/* =========== DEFAULT FORMAT END ============== */

function sum(arr) {
    let res = 0;
    for (let a of arr) {
        res += a;
    }
    return res;
}

const countObj = (arr, val)  => arr.reduce((a, v) => (v == val ? a + 1 : a), 0);

function solve(input) {
    // YOUR BUGS HERE...
    input.forEach(el => {
        let ans = 'NO'
        let a = el[1].split(' ').map(i => parseInt(i));
        const sumA = sum(a);
        if (sumA % 2 !== 0) {
            ans = 'NO'
        } else {
            const halfSum = sumA / 2;
            if (halfSum === 1 && a[0] === 1) {
                ans = 'YES';
            } else if (halfSum % 2 === 0) {
                ans = countObj(a, 2) >= (halfSum / 2) || countObj(a, 1) >= halfSum ? 'YES' : 'NO';
            } else if (halfSum % 2 !== 0) {
                ans = (countObj(a, 2) >= ((halfSum - 1) / 2) && countObj(a, 1) >= 1) || countObj(a, 1) >= halfSum ? 'YES' : 'NO'
            }
        }
        console.log(ans);
    });
}

/** =========== DEFAULT FORMAT ==============
 *
 * use this format to solve problem that use more than 1 inputs per testcase
 *
 *  */
function set_n_line() {
    // set return 0 if the problem needs dynamic n line inputs
    // set return n > 0 if the problem needs fixed n  line inputs
    return 2
}
const readline = require('readline').createInterface({ input: process.stdin });
let inputs = []; let sub_input = []; let t = 0; let n_line_subinput = set_n_line();
function fillInput(line) {
    // dynamic n_line
    if (n_line_subinput == 0) n_line_subinput = parseInt(line)
    else if (sub_input.length < n_line_subinput) {
        sub_input.push(line)
        if (sub_input.length == n_line_subinput) {
            inputs.push(sub_input); sub_input = [];
            n_line_subinput = set_n_line();
        }
    }
}

readline.on('line', line => {
    if (t == 0) t = parseInt(line)
    else if (inputs.length < t) {
        fillInput(line)
        if (inputs.length == t) { solve(inputs);readline.close() }
    }
});
/* =========== DEFAULT FORMAT END ============== */

let i = '';
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL).filter((line) => line);
    console.log(processInput(lines));
});

const processInput = (lines) => {
    return lines
        .slice(1)
        .filter((_, i) => i % 2)
        .map((line) => line.split(' '))
        .map((nums) => {
            const balance = nums.sort((a, b) => b - a).reduce((acc, num) => Math.abs(acc - num));
            return balance === 0 ? 'YES' : 'NO';
        })
        .join('\n');
};

'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++];
}
/**
5
2
1 1
2
1 2
4
1 2 1 2
3
2 2 2
3
2 1 2

**/

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

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline());
    let a = readline().split(" ").map(Number);

    var sum = a.reduce((a, b) => a + b, 0);

    if (sum % 2 !== 0) {
        console.log('NO');
        return;
    }

    var half = sum / 2;
    var dp = [];

    dp[0] = true;

    for (var index = 0; index < a.length; ++ index) {
        var num = a[index];
        for (var i = half; i >= num; -- i) {
            dp[i] = dp[i] || dp[i - num];
        }
    }

    if(dp[half] === true) {
        console.log('YES');
        return;
    }

    console.log('NO');

}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var one = 0;
		var two = 0;
		for(var j = 0; j < N; j++){
			if(list[j] == 1){
				one++;
			}else{
				two++;
			}
		}
		if(one % 2 == 1){
			myout("NO");
			continue;
		}
		if(two % 2 == 0){
			myout("YES");
		}else{
			if(one > 0){
				myout("YES");
			}else{
				myout("NO");
			}
		}
	}
}

/*
** Template
*/

// Common Template Starts //
//*
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++];
}
// Common Template Ends //

const isOdd = (x) => { return x & 1 }
const isEven = (x) => { return !(x & 1) }
const sortAsc = (arr) => arr.sort((a, b) => a - b)
const sortDesc = (arr) => arr.sort((a, b) => b - a)
const sum = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)

const getResult = (n, candies) => {

    if (n === 1) return 'NO'
    if (n === 2) return (candies[0] === candies[1]) ? 'YES' : 'NO'

    totalWeight = sum(candies)
    if (isOdd(totalWeight)) return 'NO'

    let ones = candies.filter(c => c === 1)
    let twos = candies.filter(c => c === 2)

    if (ones.length === 0) return isEven(twos.length) ? 'YES' : 'NO'
    if (twos.length === 0) return isEven(ones.length) ? 'YES' : 'NO'

    sortDesc(candies)
    let mid = totalWeight / 2
    let left = 0
    let right = n - 1

    for (let i = 0; i < twos.length; i++) {
        left += twos[i]
        if (left > mid) {
            left -= twos[i]
            break
        }
    }

    for (let i = 0; i < ones.length; i++) {
        left += ones[i]
        if (left > mid) {
            left -= ones[i]
            break
        }
    }

    if (left === mid) return 'YES'

    return 'NO'
}

function main() {
    let testcases = parseInt(readline())
    while (testcases--) {

        let n = readline()
        let candies = readline()

        n = parseInt(n)
        candies = candies.split(' ').map(Number)
        console.log(getResult(n, candies))
    }
}
//*/

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

var standardInputString = "";
var currentLine = 0;

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

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  let t = +readline();
  while (t--) {
    let n = +readline();
    let arr = readline()
      .split(" ")
      .map((val) => +val);
    let count = [null, 0, 0];
    for (let i = 0; i < arr.length; ++i) {
      count[arr[i]]++;
    }
    if (count[1] % 2 !== 0) console.log("NO");
    else if (count[2] % 2 !== 0 && count[1] === 0) console.log("NO");
    else {
      console.log("YES");
    }
  }
}

const { EOL } = require('os');

let input = ''
process.stdin.on('data', data => input += data);
process.stdin.on('end', () => {
    const lines = input.split(EOL);
    let numtests = parseInt(lines[0])
    let numCandies = []
    let candyWeights = []
    for(let i=1; i<lines.length-1; i++) {
        if(i%2==1) {
            numCandies.push(parseInt(lines[i]))
        }
        else {
            candyWeights.push(lines[i].split(' '))
        }
    }
    candyWeights = candyWeights.map(x => x.map(y => parseInt(y)))
    for(let i=0; i<numCandies.length; i++) {
        if(candyWeights[i].reduce((a,b) => a + b, 0)%2===0) {
            if(candyWeights[i].length%2===0) {
                console.log('YES')
            } else {
                // number of ones needs to be even
                if(candyWeights[i].reduce((a,b) => a + (b==2? 0: 1), 0)%2==0 && candyWeights[i].reduce((a,b) => a + (b==2? 0: 1), 0)!==0) {
                    console.log('YES')
                } else {
                    console.log('NO')
                }
            }
        } else {
            console.log('NO')
        }
    }
});

'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++];
}

function main() {
  const x = readline();

  for (let i = 0; i < x; i++) {
    let n = readline();
    let c = readline().split(' ').map(x => +x);
    let o = c.filter(x => x === 1);
    let t = c.filter(x => x === 2);

    if (t.length % 2 === 0 && o.length % 2 === 0) {
      console.log('yes');
    } else if (o.length > 0 && (o.length - 2) % 2 === 0 && t.length % 2 !== 0) {
      console.log('yes');
    } else {
      console.log('no');
    }
  }
}

'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() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        var sum = 0
        var number = 0
        var array = readline().split(' ').map(x => {
            sum += Number(x)
            if (Number(x) === 1) number += 1
            return Number(x)
        });
        if (sum % 2 === 0 && (sum / 2) % 2 === 1 && number < 2) return console.log('NO')
        console.log(sum % 2 === 0 ? "YES" : 'NO')
    })

}

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++){
		nl.num();
		let k = nl.nums();
		let a = [0, 0];
		k.forEach((e) => {
			a[e-1]++;
		});
		if (a[1]%2 === 0){
			ans.push(a[0]%2 === 0);
		} else {
			ans.push(a[0] > 0 && (a[0] - 2)%2 === 0)
		}
	}
	console.log(ans.map(e => e?'YES':'NO').join('\n'));
};

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

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        // taking input and assingn variables...
        let n = +input[z++];
        let arr = input[z++].split(' ').map(x=>Number(x));
        let total = 0;

        for (const val of arr) {
            total += val;
        }
        if(total % 2 === 1){
            console.log("NO");
        }
        else{
            if(n % 2 === 0){
                console.log("YES");
            }
            else{
                let oneCount = 0;
                let twoCount = 0;
                for (const val of arr) {
                    if(val === 1) oneCount++;
                    else twoCount++;
                }
                if(oneCount === 0 || twoCount === 0){
                    console.log("NO");
                }
                else{
                    if(oneCount % 2 === 1){
                        console.log("NO");
                    }
                    else{
                        console.log("YES");
                    }
                }
            }
        }
    }
}

const { EOL } = require('os')
let i = ''
process.stdin.on('data', c => (i += c))
process.stdin.on('end', () => {
  const { EOL } = require('os')
  const lines = i.split(EOL).filter(line => line)
  console.log(processInput(lines))
})

const processInput = lines => {
  return lines
    .slice(1)
    .filter((_, i) => i % 2)
    .map(line => line.split(' '))
    .map(nums => {
      const balance = nums
        .sort((a, b) => b - a)
        .reduce((acc, num) => Math.abs(acc - num))
      return balance === 0 ? 'YES' : 'NO'
    })
    .join(EOL)
}

const write = out => process.stdout.write(out + `\n`);

const mainCode = ([l1, l2]) => {
	l1 = Number(l1);
	l2 = l2.split(' ').map(Number);

	let ones = 0, twos = 0;
	l2.map(e => {
		if (e == 1) ones++;
		else twos++;
	})

	let total = ones + twos * 2;
	if (total % 2 != 0) write('NO');
	else {
		if ((total / 2) % 2 == 0) write('YES')
		else {
			if (ones > 0) write('YES');
			else write('NO');
		}
	}
}

let counter = 0;
let t = 0;
const t_size = 2;

const cases = [];

const lineInterpreter = (line) => {
	if (counter == 0) t = Number(line)
	else {
		const cursor = (counter - 1) % t_size
		if (cursor == 0) cases.push([line])
		else cases[cases.length - 1].push(line)
	}

	if (counter == (t * t_size)) {
		cases.map(_case => mainCode(_case))
	}
	counter++
}

const platform = 1;

if (platform > 0) {

	// FOR CODEFORCES

	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();
	    });

		inputString.map(line => lineInterpreter(line));
	});
} else {

	// FOR PERSONAL USE

	const sample = `5
2
1 1
2
1 2
4
1 2 1 2
3
2 2 2
3
2 1 2`;
	sample.split(`\n`).map(line => lineInterpreter(line));
}

const candies = a => {
  const countOne = a.reduce((acc, item) => {
    if (item == 1) return acc + 1;
    return acc;
  }, 0);
  const countTwo = a.length - countOne;
  if (countOne % 2 == 1) return false;
  if (countTwo % 2 == 0) return true;
  if (countOne == 0) return false;
  return true;
};

const main = () => {
  let test = parseInt(readline());
  while (test--) {
    readline();
    const a = readline()
      .split(" ")
      .map(s => parseInt(s));
    if (candies(a)) console.log("YES");
    else console.log("NO");
  }
};

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 => string.trim());
  main();
});

const readline = () => {
  return inputString[currentLine++];
};

'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++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}

function create2DArray(rows) {
    var arr = [];

    for (var i = 0; i < rows; i++) {
        arr[i] = [];
    }

    return arr;
}
// ---------------------------------------

function main() {
    let t = getInt(readline());
    while(t--) {
        let len = getInt(readline());
        let arr = getArray(readline());
        let total1 = 0;
        let total2 = 0;
        for(let i=0; i<len; i++) {
            if(arr[i] === 1) {
                total1++;
            } else {
                total2++;
            }
        }
        if(total1%2 !== 0) {
            console.log('NO');
        } else {
            let total = total1 + 2*total2;
            if (total1 == 0 && total2%2 ===1) {
                console.log('NO');
            }else if(total%2 === 0) {
                console.log('YES');
            } else {
                console.log('NO');
            }
        }
    }
}

/*
f(total, k) = f(total-ki, k-1)+f(total, k-1)

*/

const solve = (n, arr) => {
    if ([...new Set(arr)].length == 1) {
        if (n % 2 == 0) {
            return console.log('YES');
        } else {
            return console.log('NO');
        }
    }
    let sum = arr.reduce((a, b) => a + b);
    if (sum % 2 == 1) return console.log('NO');
    console.log('YES');
};

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--) {
            let data = input.slice(i, i + 2);
            solve(data[0][0], data[1]);
            i += 2;
        }
    });
};

main()

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number).sort((a, b) => b - a);
  let alice = 0;
  let bob = 0;

  for (let i = 0; i < arr.length; i++) {
    if (alice > bob) {
      bob += arr[i];
    }
    else {
      alice += arr[i];
    }
  }

  if (alice === bob) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

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++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const sum = arr.reduce((acc, curr) => acc + curr, 0);
		if (sum % 2 !== 0) console.log('NO');
		else {
			const target = Math.floor(sum / 2);
			const dp = [...Array(len + 1).fill(0)].map((_) => Array(target + 1).fill(0));
			for (let i = 1; i <= len; i++) {
				for (let j = 1; j <= target; j++) {
					if (arr[i - 1] <= j) {
						dp[i][j] = Math.max(arr[i - 1] + dp[i - 1][j - arr[i - 1]], dp[i - 1][j]);
					} else {
						dp[i][j] = dp[i - 1][j];
					}
				}
			}
			if (dp[len][target] === target) {
				console.log('YES');
			} else {
				console.log('NO');
			}
		}
	}
}

let i = '';
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);

    const t = parseInt(lines[0]);

    for (let i = 1; i <= t * 2; i += 2) {
        const n = parseInt(lines[i]);
        const arr = lines[i + 1].split(' ').map(num => parseInt(num));

        console.log(solve(n, arr));
    }
});

function solve(n, arr) {
    let one = 0;
    let two = 0;

    for (let i = 0; i < n; i++) {
        if (arr[i] === 1) {
            one++;
        } else {
            two++;
        }
    }

    two = two % 2;

    if (two > 0 && one < 2) {
        return 'NO';
    } else if (two > 0) {
        one -= 2;
    }

    return one % 2 > 0 ? 'NO' : 'YES';
}

w = +readline();
for (j = 0; j < w; j++) {
  x = +readline();
  y = readline().split(" ").map(Number);
  ones = 0;
  tows = 0;
  for (i = 0; i < y.length; i++) {
    if (y[i] === 1) {
      ones++;
    } else {
      tows++;
    }
  }
  if (tows % 2 && ones && ones % 2 === 0) print("YES");
  else if (tows % 2 === 0 && ones % 2 === 0) {
    print("YES");
  } else print("NO");
}

var n = parseInt(readline())

  function equal() {
    var length = parseInt(readline())
    var a = readline()
      .split(" ")
      .map((data) => +data)
    var sum = 0;
    var one = 0;
    for (var i = 0; i < length; i++) {
      sum += a[i];
      if (a[i] == 1)
        one++;
    }
    if (sum % 2 !== 0) {
      return print("NO");
    }
    var temp = Math.floor(sum / 2);
    if (temp % 2 !== 0 && one < 2) {
      print("NO");
    } else {
      print("YES");
    }
  }

  while (n--) {
    equal()
  }

var t = +readline();

while (t--) {
  var n = +readline();
  var weights = readline().split(" ").map(Number);
  var arr = [0, 0];
  var sum = 0;

  for (var weight of weights) {
    sum += weight;
    arr[weight % 2] += 1;
  }
  var ones = arr[1];
  if (ones % 2 || (sum % 4 && !ones)) {
    print("NO");
    continue;
  }
  print("YES");
}

var t = +readline();

while (t--) {
  var n = +readline();
  var weights = readline().split(" ").map(Number);
  var sum_weights = weights.reduce((acc, item) => acc + item);
  var ones = 0;
  var twos = 0;
  var sum = weights[0];

  for (var i = 0; i < n; i++) {
    if (weights[i] === 1) {
      ones++;
    } else {
      twos++;
    }
  }

  if (ones % 2) {
    print("NO");
    continue;
  }

  if (sum_weights % 4 && ones === 0) {
    print("NO");
    continue;
  }
  print("YES");
}

var t =readline();
for (var i = 0 ; i < t ; i++){
    var n = readline();
    var a = readline().split(' ');
    var one = 0  , two = 0 , counter = 0;
    for(var j = 0 ; j < n ; j++){
        if(a[j] == '1'){
          one++;
          counter = counter + 1;
        }
        else{
          two++;
          counter = counter + 2;
        }
    }
    if(counter%2 !== 0){
        print('NO');
    }
    else if(one === 0 && two%2 !== 0){
        print('NO');
    }
    else if(one%2 === 0 && two%2 !== 0 || one%2 === 0 && two%2 === 0 ){
        print('YES');
    }
    else{
        print('NO');
    }
}

test = parseInt(readline());
while (test--) {
	    one = 0;
		two = 0;
	n = parseInt(readline());
    arr = readline().split(' ').map(x => +x);
	for (var i = 0; i < n; i++) {
		if (arr[i] == 1) one++;
		else two++;
	}

	if ((two % 2) && (one) && (one % 2)===0)
		print('YES');
	else if ((two % 2)===0 && (one % 2)===0) {
		print('YES');
	} else
		print('NO');

}

"use strict"

let iter = parseInt(readline());

for(let i = 0; i < iter; i++){
    let amount = parseInt(readline());
    let weigths = readline().split(" ").map(x => parseInt(x));
    let ones = 0;
    let twoes = 0;

    for(let j = 0; j < amount; j++){
        if(weigths[j] === 1){
            ones++;
        } else {
            twoes++;
        }
    }

    if(ones > 1 && twoes % 2 === 1){
        ones -= 2;
        twoes++;
    }

    if(ones % 2 === 0 && twoes % 2 === 0){
        print("YES");
    } else {
        print("NO");
    }
}

T = readline()

while (T--) {
    n = readline()
    a = readline().split(' ').map(x => +x)
    sumOne = 0;
    sumTwo = 0;
    for (i = 0; i < n; i++) {
        if(a[i]==1)
            sumOne++
        else
            sumTwo++
    }
    if (sumTwo % 2 != 0) {
        if ((sumOne % 2 == 0)&&(sumOne>1))
            print('YES')
        else
            print('NO')
    }
    else {
        if (sumOne%2==0)
            print('YES')
        else
            print('NO')
    }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = rl().split(" ");
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let len1 = arr.filter((a) => a == 1).length;
    let len2 = n - len1;

    let ar1 = len1 % 2 === 0 && len1 > 1;
    let ar2 = len2 % 2 === 0 && len2 > 1;

    if (len1 === 0 && ar2) cl("Yes");
    else if (ar1 && (ar2 || !ar2)) cl("Yes");
    else cl("No");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 === 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = rl().split(" ");
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let len1 = 0;
    let len2 = 0;
    arr.forEach((a) => {
      a == 1 ? len1++ : len2++;
    });

    let ar1 = isEven(len1);
    let ar2 = isEven(len2);

    if (len1 === 0 && ar2) cl("Yes");
    else if (ar1 && len2 === 0) cl("Yes");
    else if (ar1 && (ar2 || !ar2)) cl("Yes");
    else cl("No");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 === 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = numArray(rl());
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let len1 = arr.filter((a) => a === 1).length;
    let len2 = arr.filter((a) => a === 2).length;

    let ar1 = isEven(len1);
    let ar2 = isEven(len2);

    if (len1 === 0 && ar2) cl("Yes");
    else if (ar1 && len2 === 0) cl("Yes");
    else if (ar1 && (ar2 || !ar2)) cl("Yes");
    else cl("No");
  }
}

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

              if (alice === bob) {
                console.log('YES')
              }
              else {
                console.log('NO')
              }
        }
    }

});

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 === 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = numArray(rl());
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let len1 = arr.filter((a) => a == 1).length;
    let len2 = arr.filter((a) => a == 2).length;

    let ar1 = isEven(len1);
    let ar2 = isEven(len2);

    if (len1 == 0 && ar2) cl("Yes");
    else if (ar1 && len2 == 0) cl("Yes");
    else if (ar1 && ar2) cl("Yes");
    else cl("No");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 === 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = numArray(rl());
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let ar1 = isEven(arr.filter((a) => a == 1).length);
    let ar2 = isEven(arr.filter((a) => a == 2).length);
    if (ar1 || ar2) cl("Yes");
    else cl("No");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 === 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = numArray(rl());
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let ar1 = isEven(arr.filter((a) => a == 1).length);
    let ar2 = isEven(arr.filter((a) => a == 2).length);

    if ((!ar1 && !ar2) || (ar1 !== 0 && !ar1 && ar2)) cl("No");
    else cl("Yes");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 === 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const ln1 = rl();
    const ln2 = numArray(rl());
    solution(+ln1, ln2);
  }
  /************************Solution****************************************/
  function solution(n, arr) {
    let ar1 = isEven(arr.filter((a) => a == 1).length);
    let ar2 = isEven(arr.filter((a) => a == 2).length);

    if ((!ar1 && !ar2) || (!ar1 && ar2)) cl("No");
    else cl("Yes");
  }
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    for(j = 1; j <= lines[0]; j++){
        var a = lines[j]
        for(k = 2; k < a; k++){
            var b = lines[k].split(' ')
            var l = 0
            if(a == 2){
                l = b[0] + b[1]
            }else if(a == 3){
                l = b[0] + b[1] + b[2]
            } else if(a == 4){
                l = b[0] + b[1] + b[2] + b[3]
            }
            if(l % 2 === 0){
                console.log('YES')
            }else {
                console.log('NO')
            }
        }

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var s = false
    for(j = 1; j <= lines[0] ; j++){
            var b = lines[j+1].split(' ')
            var l = b[0] + b[1]
            if(l % 2 === 0){
                console.log('YES')
            }else{
                console.log('NO')
            }

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var cases = lines[0];
    var totalWeight = 0;
    for(var j = 1; j < Number(cases) + 1; j++){
        var candies = lines[j + j - 1].split(' ').map(Number);
        var weight = lines[j + j].split(' ').map(Number);
        for(k = 0; k < candies; k++){
            totalWeight = weight[j] + weight[j];
        }
        if(totalWeight % 2 === 0){
            console.log('YES');
        }
        else{
            console.log('NO');
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var cases = lines[0];
    for(var j = 1; j < Number(cases) + 1; j++){
        var candies = lines[j + j - 1].split(' ').map(Number);
        var weight = lines[j + j].split(' ').map(Number);
        var totalWeight = weight[j] + weight[j];
        if(totalWeight % 2 === 0){
            console.log('YES');
        }
        else{
            console.log('NO')
        }
    }
});

'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() {
  let t = Number(readline());
  while (t--) {
    const n = Number(readline());
    let sum = 0;
    let candies = readline().split(' ').map(Number);
    let ones = 0;
    for (let c of candies) {
      sum += c;
      if (c === 1) ones++;
    }
    if (
      sum % 2 === 0 &&
      ((ones === 0 && n % 2 === 0) ||
        (ones !== 0 &&
          (((ones / 2) % 2 === 1 && n - ones > 1) || (ones / 2) % 2 === 0)))
    ) {
      console.log('YES');
    } else {
      console.log('NO');
    }
  }
}

'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() {
  let t = Number(readline());
  while (t--) {
    const n = Number(readline());
    let sum = 0;
    let candies = readline().split(' ').map(Number);
    let ones = 0;
    for (let c of candies) {
      sum += c;
      if (c === 1) ones++;
    }
    if (
      sum % 2 === 0 &&
      ((ones === 0 && n % 2 === 0) ||
        (ones !== 0 &&
          (((ones / 2) % 2 === 1 && n % 2 === 0) || (ones / 2) % 2 === 0)))
    ) {
      console.log('YES');
    } else {
      console.log('NO');
    }
  }
}

'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() {
  let t = Number(readline());
  while (t--) {
    const n = Number(readline());
    if (n % 2 === 1) {
      console.log('NO');
    } else {
      let sum = 0;
      let candies = readline().split(' ').map(Number);
      for (let c of candies) sum += c;
      if (sum % 2 === 0) {
        console.log('YES');
      } else {
        console.log('NO');
      }
    }
  }
}

const { Console } = require("console");
const { RSA_X931_PADDING } = require("constants");
const { maxHeaderSize } = require("http");
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const array = input.slice(1).map(val => val.split(" ").map(v => Number(v)));
    let n = 0;

    for(let idx in array) {
        if(idx % 2 === 0) n = array[idx];
        else {
            if(n == 1) {
                console.log("NO");
            } else {
                const one = array[idx].join("").match(/1/g);
                const two = array[idx].join("").match(/2/g);
                let cnt1 = 0, cnt2 = 0;

                if(one !== null) cnt1 = one.length;
                if(two !== null) cnt2 = two.length;

                const sum = cnt1 + 2 * cnt2;

                if(sum % 2 !== 0) {
                    console.log("NO");
                } else {
                    if(cnt1 % 2 === 0 && cnt2 % 2 === 0) console.log("YES");
                    else {
                        if(cnt1 % 2 === 0 && cnt2 % 2 !== 0) console.log("YES");
                        else {
                            if(cnt1 % 2 !== 0) console.log("NO");
                            else console.log("YES")
                        }
                    }
                }
            }
        }
    }
}

const { Console } = require("console");
const { RSA_X931_PADDING } = require("constants");
const { maxHeaderSize } = require("http");
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const array = input.slice(1).map(val => val.split(" ").map(v => Number(v)));
    let n = 0;

    for(let idx in array) {
        let check = false;
        if(idx % 2 === 0) n = array[idx];
        else {
            if(n % 2 !== 0) {
                console.log("NO");
            } else {
                const one = array[idx].join("").match(/1/g);
                const two = array[idx].join("").match(/2/g);

                if(one !== null) check = one.length % 2 === 0 ? true : false;
                if(two !== null) check = two.length % 2 === 0 ? true : false;

                check === true ? console.log("YES") : console.log("NO");
            }
        }
    }
}

function sum(arr) {
    let res = 0;
    for (let a of arr) {
        res += a;
    }
    return res;
}

const countObj = (arr, val)  => arr.reduce((a, v) => (v == val ? a + 1 : a), 0);

function solve(input) {
    // YOUR BUGS HERE...
    input.forEach(el => {
        let ans = 'NO'
        let a = el[1].split(' ').map(i => parseInt(i));
        const sumA = sum(a);
        if (sumA % 2 !== 0) {
            ans = 'NO'
        } else {
            const halfSum = sumA / 2;
            if (halfSum === 1 && a[0] === 1) {
                ans = 'YES';
            } else if (halfSum % 2 === 0) {
                ans = countObj(a, 2) >= (halfSum / 2) || countObj(a, 1) >= halfSum ? 'YES' : 'NO';
            } else if (halfSum % 2 !== 0) {
                ans = countObj(a, 2) >= ((halfSum - 1) / 2) && countObj(a, 1) >= 1 ? 'YES' : 'NO'
            }
        }
        console.log(ans);
    });
}

/** =========== DEFAULT FORMAT ==============
 *
 * use this format to solve problem that use more than 1 inputs per testcase
 *
 *  */
function set_n_line() {
    // set return 0 if the problem needs dynamic n line inputs
    // set return n > 0 if the problem needs fixed n  line inputs
    return 2
}
const readline = require('readline').createInterface({ input: process.stdin });
let inputs = []; let sub_input = []; let t = 0; let n_line_subinput = set_n_line();
function fillInput(line) {
    // dynamic n_line
    if (n_line_subinput == 0) n_line_subinput = parseInt(line)
    else if (sub_input.length < n_line_subinput) {
        sub_input.push(line)
        if (sub_input.length == n_line_subinput) {
            inputs.push(sub_input); sub_input = [];
            n_line_subinput = set_n_line();
        }
    }
}

readline.on('line', line => {
    if (t == 0) t = parseInt(line)
    else if (inputs.length < t) {
        fillInput(line)
        if (inputs.length == t) { solve(inputs);readline.close() }
    }
});
/* =========== DEFAULT FORMAT END ============== */

let i = '';
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL).filter((line) => line);
    console.log(processInput(lines));
});

const processInput = (lines) => {
    return lines
        .slice(1)
        .filter((_, i) => i % 2)
        .map((line) => line.split(' '))
        .map((nums) => {
            const balance = nums.sort((a, b) => a - b).reduce((acc, num) => Math.abs(acc - num));
            return balance === 0 ? 'YES' : 'NO';
        })
        .join('\n');
};

let i = '';
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL).filter((line) => line);
    console.log(processInput(lines));
});

const processInput = (lines) => {
    return lines
        .slice(1)
        .filter((_, i) => i % 2)
        .map((line) => line.split(' '))
        .map((nums) => {
            let nOf1 = 0,
                nOf2 = 0;
            for (const num of nums) {
                if (num === '1') nOf1++;
                else nOf2++;
            }
            return nOf1 % 2 === 0 && nOf2 % 2 === 0 ? 'YES' : 'NO';
        })
        .join('\n');
};

'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++];
}
/**
5
2
1 1
2
1 2
4
1 2 1 2
3
2 2 2
3
2 1 2

**/

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

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline());
    let a = readline().split(" ");

    let k = 0;
    let j = 0;

    for(let i=0;i<a.length;i++) {
        if(a[i] === '1') {
            k++;
        } else {
            j++;
        }
    }

    if(k % 2 === 0 && j % 2 === 0) {
        console.log('YES');
        return;
    }

    console.log('NO');

}

'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++];
}
/**
5
2
1 1
2
1 2
4
1 2 1 2
3
2 2 2
3
2 1 2

**/

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

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline());
    let a = readline().split(" ");

    let set = new Set(a);
    //console.log(set)
    if( n === set.size * 2) {
        console.log('YES');
        return;
    }

    console.log('NO');

}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var one = 0;
		var two = 0;
		var sum = list[0];
		for(var j = 1; j < N; j++){
			sum += list[j];
			list[j] += list[j - 1];
		}
		var isOK = false;
		for(var j = 0; j < N; j++){
			if(sum / 2 == list[j]){
				isOK = true;
			}
		}
		myout((isOK) ? "YES" : "NO");
	}
}

/*
** Template
*/

// Common Template Starts //
//*
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++];
}
// Common Template Ends //

const isOdd = (x) => { return x & 1 }
const isEven = (x) => { return !(x & 1) }
const sortAsc = (arr) => arr.sort((a, b) => a - b)
const sum = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)

function findMinDiff(arr, n) {

    let sum = 0
    let left2right = [1]
    let right2left = [1]

    for (let i = 1; i < n; i++) {
        if (arr[i] > arr[i - 1]) {
            left2right[i] = left2right[i - 1] + 1
        }
    }

    for (let i = n - 2; i >= 0; i--) {
        if (arr[i] > arr[i + 1]) {
            right2left[i] = right2left[i + 1] + 1
        }
    }

    for (let i = 0; i < n; i++) {
        sum += Math.max(left2right[i], right2left[i])
    }

    return sum
}

const getResult = (n, candies) => {

    if (n === 1) return 'NO'
    if (n === 2) return (candies[0] === candies[1]) ? 'YES' : 'NO'

    totalWeight = sum(candies)
    if (isOdd(totalWeight)) return 'NO'

    sortAsc(candies)

    let minDiff = findMinDiff(candies, n)
    return minDiff === 0 ? 'YES' : 'NO'
}

function main() {
    let testcases = parseInt(readline())
    while (testcases--) {

        let n = readline()
        let candies = readline()

        n = parseInt(n)
        candies = candies.split(' ').map(Number)
        console.log(getResult(n, candies))
    }
}
//*/

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

var standardInputString = "";
var currentLine = 0;

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

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  let t = +readline();
  while (t--) {
    let n = +readline();
    let arr = readline()
      .split(" ")
      .map((val) => +val);
    let count = [null, 0, 0];
    for (let i = 0; i < arr.length; ++i) {
      count[arr[i]]++;
    }
    if (
      count[1] === count[2] &&
      (count[1] + count[2]) % 2 === 0 &&
      count[1] !== 1 &&
      count[2] !== 1
    ) {
      console.log("YES");
    } else if (
      (count[1] === 0 && count[2] % 2 === 0) ||
      (count[2] === 0 && count[1] % 2 === 0)
    ) {
      console.log("YES");
    } else {
      console.log("NO");
    }
  }
}

const { EOL } = require('os');

let input = ''
process.stdin.on('data', data => input += data);
process.stdin.on('end', () => {
    const lines = input.split(EOL);
    console.log(lines)
    let numtests = parseInt(lines[0])
    let numCandies = []
    let candyWeights = []
    for(let i=1; i<lines.length-1; i++) {
        if(i%2==1) {
            numCandies.push(parseInt(lines[i]))
        }
        else {
            candyWeights.push(lines[i].split(' '))
        }
    }
    candyWeights = candyWeights.map(x => x.map(y => parseInt(y)))
    for(let i=0; i<numCandies.length; i++) {
        console.log(candyWeights[i])
        if(candyWeights[i].reduce((a,b) => a + b, 0)%2===0) {
            if(candyWeights[i].length%2===0) {
                console.log('YES')
            } else {
                // number of ones needs to be even
                if(candyWeights[i].reduce((a,b) => a + (b==2? 0: 1), 0)%2==0 && candyWeights[i].reduce((a,b) => a + (b==2? 0: 1), 0)!==0) {
                    console.log('YES')
                } else {
                    console.log('NO')
                }
            }
        } else {
            console.log('NO')
        }
    }
});

'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++];
}

function main() {
  const x = readline();

  for (let i = 0; i < x; i++) {
    let n = readline();
    let c = readline().split(' ').map(x => +x);
    c.sort();

    let s1 = 0;
    let s2 = 0;

    for(let i = 0; i <= n && i + 1 <= n; i+=2) {
      s1 += c[i];
      s2 += c[i + 1];
    }

    console.log(s1 === s2 ? 'yes' : 'no');
  }
}

'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() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        var sum = 0
        var array = readline().split(' ').map(x => {
            sum+=Number(x)
            return Number(x)
        });

        console.log(sum % 2 ===0 ? "YES":'NO')
    })

}

w = +readline();
for (j = 0; j < w; j++) {
  x = +readline();
  y = readline().split(" ").map(Number);
  ones = 0;
  tows = 0;
  for (i = 0; i < y.length; i++) {
    if (y[i] === 1) {
      ones++;
    } else {
      tows++;
    }
  }
  if (ones === tows && ones !== 1 && tows !== 1) {
    print("YES");
  } else {
    if (
      (ones % 2 === 0 && tows % 2 === 0) ||
      (ones % 2 === 1 && tows % 2 === 1)
    ) {
      print("YES");
    } else {
      print("NO");
    }
  }
}

w = +readline();
for (j = 0; j < w; j++) {
  x = +readline();
  y = readline().split(" ").map(Number);
  ones = 0;
  tows = 0;
  for (i = 0; i < y.length; i++) {
    if (y[i] === 1) {
      ones++;
    } else {
      tows++;
    }
  }
  if (ones === tows && ones !== 1 && tows !== 1) {
    print("YES");
  } else {
    if (ones % 2 === 0 && tows % 2 === 0) {
      print("YES");
    } else {
      print("NO");
    }
  }
}

w = +readline();
for (j = 0; j < w; j++) {
  x = +readline();
  y = readline().split(" ").map(Number);
  ones = 0;
  for (i = 0; i < y.length; i++) {
    if (y[i] === 1) {
      ones += y[i];
    } else {
      continue;
    }
  }
  if (x / 2 === ones) {
    print("YES");
  } else {
    print("NO");
  }
}

w = +readline();
for (j = 0; j < w; j++) {
  x = +readline();
  y = readline().split(" ").map(Number).sort();
  ones = 0;
  twos = 0;
  for (i = 0; i < x; i++) {
    if (y[i] === 1) {
      ones++;
    } else {
      twos++;
    }
  }
  if ((ones % 2 === 0 && twos % 2 === 0) || ones === twos) {
    print("YES");
  } else {
    print("NO");
  }
}

w = +readline();
ones = 0;
twos = 0;
for (j = 0; j < w; j++) {
  x = +readline();
  y = readline().split(" ").map(Number).sort();
  for (i = 0; i < x; i++) {
    if (y[i] === 1) {
      ones++;
    } else {
      twos++;
    }
  }
  if (ones === twos) {
    print("YES");
  } else {
    print("NO");
  }
}

w = +readline();
for (j = 0; j < w; j++) {
  x = +readline();
  y = readline().split(" ").map(Number).sort();
  ones = 0;
  twos = 0;
  for (i = 0; i < x; i++) {
    if (y[i] === 1) {
      ones++;
    } else {
      twos++;
    }
  }
  if (ones === twos) {
    print("YES");
  } else {
    print("NO");
  }
}

x = +readline();
y = readline().split(" ").map(Number).sort();
ones = 0;
twos = 0;
for (i = 0; i < x; i++) {
  if (y[i] === 1) {
    ones++;
  } else {
    twos++;
  }
}
if (ones === twos) {
  print("YES");
} else {
  print("NO");
}

var n = parseInt(readline())

  function equal() {
    var length = parseInt(readline())
    var a = readline()
      .split(" ")
      .map((data) => +data)
    var sum = 0;
    var one = 0;
    for (var i = 0; i < length; i++) {
      sum += a[i];
      if (a[i] == 1)
        one++;
    }
    if (sum % 2 !== 0) {
      return print("NO");
    }
    var temp = Math.floor(sum / 2);
    if (temp >= 1 && one < 2) {
      print("NO");
    } else {
      print("YES");
    }
  }

  while (n--) {
    equal()
  }

var n = parseInt(readline())

  function equal() {
    var length = parseInt(readline())
    var a = readline()
      .split(" ")
      .map((data) => +data)
    var sum = 0;
    var one = 0;
    for (var i = 0; i < length; i++) {
      sum += a[i];
      if (a[i] == 1)
        one++;
    }
    if (sum % 2 !== 0) {
      return print("NO");
    }
    var temp = Math.floor(sum / 2);
    if (temp > 1 && one < 2) {
      print("NO");
    } else {
      print("YES");
    }
  }

  while (n--) {
    equal()
  }

var input = parseInt(readline());

  for (var i = 0; i < input; i++) {
    var n = parseInt(readline());
    var weight = readline().split(" ");

    var one = weight.filter((data) => data === "1").length;
    var two = weight.filter((data) => data === "2").length;
    if (one % 2 === 0 && (two % 2 === 0 || two === 1) && one > 0 && two > 0) {
      print("YES");
    } else if (two % 2 === 0 && two > 0 && one === 0) {
      print("YES");
    } else if (one % 2 === 0 && one > 0 && two === 0) {
      print("YES");
    } else {
      print("NO");
    }
  }

var input = parseInt(readline());

  for (var i = 0; i < input; i++) {
    var n = parseInt(readline());
    var weight = readline().split(" ");

    var one = weight.filter((data) => data === "1").length;
    var two = weight.filter((data) => data === "2").length;
    if (one % 2 === 0 && two % 2 === 0 && one !== 0 && two !== 0) {
      print("YES");
    } else if (two % 2 === 0 && two !== 0 && one === 0) {
      print("YES");
    } else if (one % 2 === 0 && one !== 0 && two === 0) {
      print("YES");
    } else {
      print("NO");
    }
  }

var t = +readline();

for(var i = 0; i < t; i++) {
    var n = +readline();
    var weights = readline().split(' ').map(Number);
    var sum_weights = weights.reduce((acc, item) => acc + item);
    var qnt_1 = 0;
    var qnt_2 = 0;

    for(var j = 0; j < n; j++) {
        if(weights[j] === '1') {
            qnt_1++;
        } else {
            qnt_2++
        }
    }

    if(sum_weights % 2 === 0) {
        if(qnt_1 % 2 === 0 && qnt_2 % 2 === 0) {
            print('YES');
        } else {
            print('NO');
        }
    } else {
        print('NO');
    }
}

'use strict'

let t = readline();
    while(t--)
    {
        let n = +readline();
        let a = readline().split(" ");
        if(a.length == 1)print("NO")
        else
        {
            a.sort();
            let i = 0, j = 0;
            while(a[i] == 1)i++;
            while(a[a.length - 1 - j] == 2)j++;
            print(((i%2 && i) || (j%2 && j))? "NO" : "YES");
        }

    }

'use strict'

let t = readline(1);
    while(t--)
    {
        let n = +readline(2);
        let a = readline("1 2").split(" ");
        a.sort();
        let i = 0, j = 0;
        while(a[i] == 1)i++;
        while(a[a.length - 1 - j] == 2)j++;
        print(((i%2 && i) || (j%2 && j))? "NO" : "YES");
    }

var t =readline();
for (var i = 0 ; i < t ; i++){
    var n = readline();
    var a = readline().split(' ');
    var one = 0  , two = 0;
    for(var j = 0 ; j < n ; j++){
        if(a[j] == '1'){
          one++;
        }
        else{
          two++;
        }
    }
    if(one%2 === 0 && two%2 === 0 ){
        print('YES');
    }
    else{
        print('NO');
    }
}

"use strict"

let iter = parseInt(readline());

for(let i = 0; i < iter; i++){
    let amount = parseInt(readline());
    let weigths = readline().split(" ").map(x => parseInt(x));
    let ones = 0;
    let twoes = 0;

    for(let j = 0; j < amount; j++){
        if(weigths[j] === 1){
            ones++;
        } else {
            twoes++;
        }
    }

    if(ones % 2 === 0 && twoes % 2 === 0){
        print("YES");
    } else {
        print("NO");
    }
}