Thanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers* to remove the first or the second half of the items, and repeat the process.Given an input array, what is the size of the longest sorted array you can obtain from it using Thanos sort?*Infinity Gauntlet required.

The first line of input contains a single number $$$n$$$ ($$$1 \le n \le 16$$$) — the size of the array. $$$n$$$ is guaranteed to be a power of 2. The second line of input contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 100$$$) — the elements of the array.

Return the maximal length of a sorted array you can obtain using Thanos sort. The elements of the array have to be sorted in non-decreasing order.

NoteIn the first example the array is already sorted, so no finger snaps are required.In the second example the array actually has a subarray of 4 sorted elements, but you can not remove elements from different sides of the array in one finger snap. Each time you have to remove either the whole first half or the whole second half, so you'll have to snap your fingers twice to get to a 2-element sorted array.In the third example the array is sorted in decreasing order, so you can only save one element from the ultimate destruction.

let i = '';

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

    var n = Number(lines[0]);
    var t = lines[1].split(' ');
    t = t.map(x=>Number(x));

   console.log(minSorted(t, 0, n-1));
})

function minSorted(u, x, y) {
   var length = y-x+1;
	var middle = x+length/2-1;
	if(isSorted(u,x,y)) return length;
	else return Math.max(minSorted(u,x,middle),minSorted(u,middle+1,y));
}

function isSorted(u, x, y) {
   for (var i=x+1;i<=y;i++) {
       if(u[i]<u[i-1]) {
		     return false;
		 }
   }
   return true;
}

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

    let size=0;
    const thanosArray = lines[1].split(' ');
    thanosArray.map((v,i,a)=>a[i]=Number(v));
    const isSorted = arr => arr.every((v,i,a) => !i || a[i-1] <= v);
    const setSize =num=> size =(size>=num)?size:num;

    const splitArray=array=>{
      if (array.length==0)
         return;
      if (isSorted(array)){
          return setSize(array.length);
      }
      else {
         let half_length = Math.ceil(array.length / 2);
         let leftSide = array.splice(0,half_length);

         splitArray(leftSide);
         splitArray(array);
      }

    }

    splitArray(thanosArray)

   console.log(size)

})

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const n = parseInt(arr[0])

  const a = arr[1].split(' ').map(a => parseInt(a))

  let ans = 1
  if(n == 1) {
    console.log(1)
    return
  }
  for(let i = 1; i < n; i++) {
    if(n >= 2 && a[i] >= a[i - 1] && (i + 1) % 2 == 0) ans = max(ans, 2)
    if(i >= 3 && n >= 4 && a[i] >= a[i - 1] && a[i - 1] >= a[i - 2] && a[i - 2] >= a[i - 3] && (i + 1) % 4 == 0) ans = max(ans, 4)
    if(i >= 7 && n >= 8 && a[i] >= a[i - 1] && a[i - 1] >= a[i - 2] && a[i - 2] >= a[i - 3] && a[i - 3] >= a[i - 4] && a[i - 4] >= a[i - 5] && a[i - 5] >= a[i - 6] && a[i - 6] >= a[i - 7] && (i + 1) % 8 == 0) ans = max(ans, 8)
    let flag = true
    if(i == 15) {
      for(let j = 1; j < n; j++) {
        if(a[j] < a[j - 1]) {
          flag = false
          break
        }
      }
    }
    if(flag && i == 15) {
      ans = 16
    }
  }
  wr(ans)
})

function wr(...x) {
  console.log(...x)
}

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

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*/

    main(lines);
})

function main(lines) {
	let n = parseInt(lines[0]);
	let a = lines[1].split(' ').map(v => {return parseInt(v)});
	console.log(helper(a, 0, n-1))

}

function helper(arr, a, b) {

	// console.log(`calling helper ${a} ${b}`);
	if(isArraySorted(arr, a, b)) {
		return b-a+1;
	} else {
		let mid = Math.floor((a+b)/2);
		return Math.max(helper(arr, a, mid), helper(arr, mid+1, b));
	}

}
function isArraySorted(arr, a, b) {

	if(a === b) {
		return true;
	}
	for(let i = a+1; i<=b; i++) {
		if(arr[i] < arr[i-1]) {
			return false;
		}
	}
	return true;

}

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

const isSorted = (arr, l, r) => {
  for (let i = l; i < r; i += 1) {
    if (arr[i] > arr[i + 1]) {
      return false;
    }
  }

  return true;
};

const getMaxArrayLength = (arr) => {
  const wrapper = (l, r) => {
    if (r <= l) {
      return 1;
    }

    if (isSorted(arr, l, r)) {
      return r - l + 1;
    }

    const half = Math.floor((r + l) / 2);

    const left = wrapper(l, half);
    const right = wrapper(half + 1, r);

    return Math.max(left, right);
  };

  return wrapper(0, arr.length - 1);
};

let n = -1;
readline.on('line', (line) => {
  if (n === -1) {
    n = Number(line);
  } else {
    const numbers = line.split(' ').map(v => Number(v));
    console.log(getMaxArrayLength(numbers));
  }
});

(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.number();
    var a = read.arrNumber(' ');

    function isSorted(arr) {
        for(var i = 1; i < arr.length; i++) {
            if(arr[i] < arr[i - 1]) {
                return false;
            }
        }
        return true;
    }

    if(isSorted(a)) {
        print(a.length);
        return;
    }

    var res = 1;

    function getPol(arr) {
        var arr1 = arr.slice(0, arr.length/2);
        if(isSorted(arr1)) {
            res = arr1.length;
            return;
        }

        var arr2 = arr.slice(arr.length/2, arr.length);
        if(isSorted(arr2)) {
            res = arr2.length;
            return;
        }

        if(arr2.length > 1 ) {
            getPol(arr1);
            getPol(arr2);
        }
    }

    getPol(a);
    print(res);
}());

var n = parseInt(readline());
var arr = readline().split(" ").map(function(item){return parseInt(item,10)});
// var n= 8;
// var arr = [11, 12, 1, 2, 13, 14, 3, 4];
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l % 2 == 0){
        k++;
        l = Math.floor(l / 2);
    }
    l = Math.pow(2, k);
    while (l > 0){
        if (kol>= l){
            if(l > max){
                max = l;
            }
        }
        l = Math.floor(l /2);
    }
    if (arr[i] <= arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

	(function main(){
		function sort(n, arr){
			function assessmentSort(arr, begin, end){
				var assessment = 0;
				var count = 0;
				for(i = begin+1; i < end; i++){
					count++;
					if(arr[i-1]>arr[i]){
						assessment += 1;
					}
				}
				return assessment;
			}
			var begin = 0; var end = n;
			var assessment = assessmentSort(arr, begin, end);
			while(assessment>0){
				var separate = (end - begin)/2 + begin;
				var assessment1 = assessmentSort(arr, begin, separate);
				var assessment2 = assessmentSort(arr, separate, end);
				if(assessment1>assessment2){
					begin = separate;
					assessment = assessment2
				}
				else {
					end = end - (end - begin)/2;
					assessment = assessment1
				}
			}
			debugger;
			return end - begin;

		}
		print(sort(readline()-0, (readline()).split(" ").map(i=>i-0)))
	})();

const n = Number(readline());
const arr = readline().split(" ").map(x => Number(x));
findLength: for (var length = n;; length >>= 1)
  findBegin: for (var begin = 0; begin < n; begin = end) {
    var end = begin + length;
    for (var i = begin + 1; i < end; i++)
      if (arr[i - 1] > arr[i]) continue findBegin;
    print(length);
    break findLength;
  }

    var sizeOfArray = readline();
    var arr = readline().split(" ").map(string => parseInt(string));

    print(thanosSort(arr));

function thanosSort(arr) {
  if (isSorted(arr)) {
    return arr.length;
  }
  var newArr1 = arr.slice(0, arr.length / 2);
  var newArr2 = arr.slice(arr.length / 2);

  var sortedLength1 = thanosSort(newArr1);
  var sortedLength2 = thanosSort(newArr2);

  return Math.max(sortedLength1, sortedLength2);
}

function isSorted(arr) {
  for (var i = 0; i < arr.length - 1; i++) {
    if (arr[i] > arr[i + 1]) {
      return false;
    }
  }
  return true;
}

var len = parseInt(readline());
var mas = readline().split(' ');

function isSorted(mas, len, subLen) {

    var k = len / subLen;
    for (var i = 0; i < k; i++) {

        var begin = i * subLen + 1;
        var end = (i + 1) * subLen;
        var sorted = true;
        for (var j = begin; j < end; j++) {
            if ( parseInt(mas[j-1]) > parseInt(mas[j]) ) {
                sorted = false;
                break;
            }
        }
        if (sorted) {
            return true;
        }

    }
    return false;
}

var subLen = len;
while (subLen > 0) {

    if (isSorted(mas, len, subLen)) {
        break;
    }
    subLen /= 2;
}
print(subLen);

function issorted(arr){
	for (i=1; i<arr.length; i++){
		if(+arr[i-1]>+arr[i]) return false;
	}
	return true;
}

function check(arr){
	if(issorted(arr)) {
		return arr.length;
	} else {
		return Math.max(check(arr.splice(arr.length/2)), check(arr));
	}
}

readline();
var arr = readline().split(' ');
print(check(arr));

var lengthA = readline();
var line2 = readline();
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] <= arr[start + 1])
            start++;
        else break;
    }

    return start === end ? true : false;
}

readline();
var a = readline().split(" ").map(function(x) { return parseInt(x); });
var sort = function(a) {
    var c = JSON.parse(JSON.stringify(a));
    var sorted = c.sort(function(a,b){
        return a - b;
    });

    if (JSON.stringify(a) == JSON.stringify(sorted)) {
        // the array is sorted
        return a.length;
    } else {
        // if the array is not sorted
        // do recursion
        var first = a.splice(0, a.length / 2);
        var firstAns = sort(first);
        var secondAns = sort(a);
        return Math.max(firstAns, secondAns);
    }

}
write(sort(a));

readline();
var inputs = readline().split(" ").map((x) => parseInt(x));

function isSorted(array) {
    var limit = array.length - 1;
    for (var i = 0; i < limit; i++) {
        var current = array[i], next = array[i + 1];
        if (current > next) { return false; }
    }
    return true;

}

function thanosSort(start, end) {
    if(start === end) {
        return 1;
    }

    var sliceInputs = inputs.slice(start, end);
    if(isSorted(sliceInputs)) {
        return sliceInputs.length;
    }

    var mid = Math.floor((start+end)/ 2);
    return Math.max(thanosSort(start, mid), thanosSort(mid, end));
}

var count = thanosSort(0, inputs.length);
print(count);

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

    let size=0;
    const thanosArray = lines[1].split(' ');
    thanosArray.map((v,i,a)=>a[i]=Number(v));
    const isSorted = arr => arr.every((v,i,a) => !i || a[i-1] <= v);
    const setSize =num=> size =(size>=num)?size:num;

    const splitArray=array=>{
      if (array.length==0)
         return;
      if (isSorted(array))
         return setSize(array.length);

      else {
         let half_length = Math.ceil(array.length / 2);
         let leftSide = array.splice(0,half_length);
         let rightSide = array.splice(half_length,array.length);

         splitArray(leftSide);
         splitArray(rightSide);
      }

    }

    splitArray(thanosArray)

   console.log(size)

})

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*/

    main(lines);
})

function main(lines) {
	let n = parseInt(lines[0]);
	let a = lines[1].split(' ').map(v => {return parseInt(v)});
	console.log(helper(a, 0, n-1))

}

function helper(arr, a, b) {
	if(isArraySorted(arr, a, b)) {
		return b-a+1;
	} else {
		mid = (a+b)/2;
		return Math.max(helper(arr, a, mid), helper(arr, mid+1, b));
	}

}
function isArraySorted(arr, a, b) {

	if(a === b) {
		return true;
	}
	for(let i = a+1; i<=b; i++) {
		if(arr[i] < arr[i-1]) {
			return false;
		}
	}
	return true;

}

var n = parseInt(readline());
var arr = readline().split(" ").map(function(item){return parseInt(item,10)});
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l > 1){
        k++;
        l /= 2;
    }
    l = Math.pow(2, k);
    if (kol>= l){
        if(l > max){
        max = l;
    }
    }
    if (arr[i] < arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

var n = parseInt(readline());
var arr = readline().split(" ").map(function(item){return parseInt(item,10)});
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l > 1){
        k++;
        l /= 2;
    }
    l = Math.pow(2, k);
    if (kol>= l){
        if(l > max){
        max = l;
    }
    }
    if (arr[i] <= arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

var n = parseInt(readline());
var arr = readline().split(" ").map((item) => {return parseInt(item,10)});
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l > 1){
        k++;
        l /= 2;
    }
    l = Math.pow(2, k);
    if (kol>= l){
        if(l > max){
        max = l;
    }
    }
    if (arr[i] < arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

function sort(n, arr){
	function assessmentSort(arr, begin, end){
		var assessment = 0;
		for(var i = begin+1; i < end; i++){
			if(arr[i-1]>arr[i]){
				assessment += 1;
			}
		}
		return assessment;
	}
	var begin = 0; var end = arr.length;
	var assessment = assessmentSort(arr, begin, end);
	while(assessment>0){
		var separate = end/2;
		var assessment1 = assessmentSort(arr, begin, separate);
		var assessment2 = assessmentSort(arr, separate, end);
		if(assessment1>assessment2){
			begin = separate;
			assessment = assessment2
		}
		else {
			end = separate;
			assessment = assessment1
		}
	}
	return end - begin;

}

print(sort(readline(), (readline()).split(" ")))

	function sort(n, arr){
		function assessmentSort(arr, begin, end){
			var assessment = 0;
			var count = 0;
			for(i = begin+1; i < end; i++){
				count++;
				if(arr[i-1]>arr[i]){
					assessment += 1;
				}
			}
			return assessment;
		}
		var begin = 0; var end = arr.length;
		var assessment = assessmentSort(arr, begin, end);
		while(assessment>0){
			var separate = end/2;
			var assessment1 = assessmentSort(arr, begin, separate);
			var assessment2 = assessmentSort(arr, separate, end);
			if(assessment1>assessment2){
				begin = separate;
				assessment = assessment2
			}
			else {
				end = separate;
				assessment = assessment1
			}
		}
		return end - begin;

	}
	print(sort(readline(), (readline()).split(" ").map(i=>i-0)))

	function sort(n, arr){
		function assessmentSort(arr, begin, end){
			var assessment = 0;
			var count = 0;
			for(i = begin+1; i < end; i++){
				count++;
				if(arr[i-1]>arr[i]){
					assessment += 1;
				}
			}
			return assessment;
		}
		var begin = 0; var end = n;
		var assessment = assessmentSort(arr, begin, end);
		while(assessment>0){
			var separate = end/2;
			var assessment1 = assessmentSort(arr, begin, separate);
			var assessment2 = assessmentSort(arr, separate, end);
			if(assessment1>assessment2){
				begin = separate;
				assessment = assessment2
			}
			else {
				end = end - (end - begin)/2;
				assessment = assessment1
			}
		}
		return end - begin;

	}
	print(sort(readline()-0, (readline()).split(" ").map(i=>i-0)))

function issorted(arr){
	for (i=1; i<arr.length; i++){
		if(+arr[i-1]>+arr[i]) return false;
	}
	return true;
}

function check(arr){
	maxLength=1;
	if(issorted(arr)) {
		maxLength=(maxLength > arr.length) ? maxLength:arr.length;
	} else {
		check(arr.splice(arr.length/2));
		check(arr);
	}
	return maxLength;
}

readline();
var arr = readline().split(' ');
print(check(arr));

function issorted(arr){
	for (i=1; i<arr.length; i++){
		if(+arr[i-1]>+arr[i]) return false;
	}
	return true;
}

function check(arr){
	print(arr, issorted(arr));
	if(issorted(arr)) {
		return arr.length;
	} else {
		return Math.max(check(arr.splice(arr.length/2)), check(arr));
	}
}

readline();
var arr = readline().split(' ');
print(check(arr));

var lengthA = readline();
print(lengthA)
var line2 = readline();
print(line2)
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start <= end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();
var line2 = readline();
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start <= end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();
var line2 = readline();
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();
print(lengthA)
var line2 = readline();
print(line2)
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();

var arr = readline().split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var a = readline().split(" ").map(function(x) { return parseInt(x); });
print(a);

readline();
var inputs = readline().split(" ").map((x) => parseInt(x));

function isSorted(array) {
    var limit = array.length - 1;
    for (var i = 0; i < limit; i++) {
        var current = array[i], next = array[i + 1];
        if (current > next) { return false; }
    }
    return true;

}

function thanosSort(start, end) {
    if(start === end) {
        return 1;
    }

    var sliceInputs = inputs.slice(start, end);
    if(isSorted(sliceInputs)) {
        return sliceInputs.length;
    }

    var mid = Math.floor((start+end)/ 2);
    return Math.max(thanosSort(start, mid -1), thanosSort(mid, end));
}

var count = thanosSort(0, inputs.length);
print(count);

readline();
var inputs = readline().split(" ").map((x) => parseInt(x));

function isSorted(array) {
    var limit = array.length - 1;
    for (var i = 0; i < limit; i++) {
        var current = array[i], next = array[i + 1];
        if (current > next) { return false; }
    }
    return true;

}

function thanosSort(start, end) {
    if(start === end) {
        return 1;
    }

    var sliceInputs = inputs.slice(start, end);
    if(isSorted(sliceInputs)) {
        return sliceInputs.length;
    }

    var mid = Math.floor((start+end)/ 2);
    return Math.max(thanosSort(start, mid -1), thanosSort(mid, end));
}

var count = thanosSort(0, inputs.length - 1);
print(count);


Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m days performing the following transformations on his string — each day he chose integer ai and reversed a piece of string (a segment) from position ai to position |s| - ai + 1. It is guaranteed that 2·ai ≤ |s|.You face the following task: determine what Pasha's string will look like after m days.

The first line of the input contains Pasha's string s of length from 2 to 2·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≤ m ≤ 105) —  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≤ ai; 2·ai ≤ |s|) — the position from which Pasha started transforming the string on the i-th day.

In the first line of the output print what Pasha's string s will look like after m days.

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.sortComparator = function( left , right ) {
		return left - right ;
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , len2 ;
        len = this.s.length ;
        res = "" ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.arr[ i ] = this.arr[ i ] - 1 ;
        }
        this.arr = this.arr.sort( this.sortComparator ) ;
        for( i = 0 ; i < len ; i++ ) {
        	this.brr[ i ] = this.s.charCodeAt( i ) ;
        }
        j = 0 ;
        cn = 0 ;
        len2 = Math.floor( len / 2 ) ;
        for( i = 0 ; i < len2 ; i++ ) {
        	while( j < this.n && this.arr[ j ] == i ) {
        		cn++ ;
        		j++ ;
        	}
        	if( cn % 2 == 0 ) {
        	}
        	else {
        		temp = this.brr[ i ] ;
        		this.brr[ i ] = this.brr[ len - i - 1 ] ;
        		this.brr[ len - i - 1 ] = temp ;
        	}
        }
        for( i = 0 ; i < len ; i++ ) {
        	res += String.fromCharCode( this.brr[ i ] ) ;
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
            this.n = irObj.nextInt();
            this.arr = new Array() ;
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , len2 ;
        len = this.s.length ;
        res = "" ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.arr[ i ] = this.arr[ i ] - 1 ;
        }
        this.arr.sort() ;
        for( i = 0 ; i < len ; i++ ) {
        	this.brr[ i ] = this.s.charCodeAt( i ) ;
        }
        j = 0 ;
        cn = 0 ;
        len2 = Math.floor( len / 2 ) ;
        for( i = 0 ; i < len2 ; i++ ) {
        	while( j < this.n && this.arr[ j ] == i ) {
        		cn++ ;
        		j++ ;
        	}
        	if( cn % 2 == 0 ) {
        	}
        	else {
        		temp = this.brr[ i ] ;
        		this.brr[ i ] = this.brr[ len - i - 1 ] ;
        		this.brr[ len - i - 1 ] = temp ;
        	}
        }
        for( i = 0 ; i < len ; i++ ) {
        	res += String.fromCharCode( this.brr[ i ] ) ;
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
            this.n = irObj.nextInt();
            this.arr = new Array() ;
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.sortComparator = function( left , right ) {
		return left > right ;
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , len2 ;
        len = this.s.length ;
        res = "" ;
        this.arr.sort( this.sortComparator ) ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.arr[ i ] = this.arr[ i ] - 1 ;
        }
        for( i = 0 ; i < len ; i++ ) {
        	this.brr[ i ] = this.s.charCodeAt( i ) ;
        }
        j = 0 ;
        cn = 0 ;
        len2 = Math.floor( len / 2 ) ;
        for( i = 0 ; i < len2 ; i++ ) {
        	while( j < this.n && this.arr[ j ] == i ) {
        		cn++ ;
        		j++ ;
        	}
        	if( cn % 2 == 0 ) {
        	}
        	else {
        		temp = this.brr[ i ] ;
        		this.brr[ i ] = this.brr[ len - i - 1 ] ;
        		this.brr[ len - i - 1 ] = temp ;
        	}
        }
        for( i = 0 ; i < len ; i++ ) {
        	res += String.fromCharCode( this.brr[ i ] ) ;
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
            this.n = irObj.nextInt();
            this.arr = new Array() ;
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


You are given a sequence $$$b_1, b_2, \ldots, b_n$$$. Find the lexicographically minimal permutation $$$a_1, a_2, \ldots, a_{2n}$$$ such that $$$b_i = \min(a_{2i-1}, a_{2i})$$$, or determine that it is impossible.

Each test contains one or more test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The first line of each test case consists of one integer $$$n$$$ — the number of elements in the sequence $$$b$$$ ($$$1 \le n \le 100$$$). The second line of each test case consists of $$$n$$$ different integers $$$b_1, \ldots, b_n$$$ — elements of the sequence $$$b$$$ ($$$1 \le b_i \le 2n$$$). It is guaranteed that the sum of $$$n$$$ by all test cases doesn't exceed $$$100$$$.

For each test case, if there is no appropriate permutation, print one number $$$-1$$$. Otherwise, print $$$2n$$$ integers $$$a_1, \ldots, a_{2n}$$$ — required lexicographically minimal permutation of numbers from $$$1$$$ to $$$2n$$$.

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

    function foo (data) {
        const dataSet = new Set(data);
        const result = [];
        const available = Array(data.length);
        for (let k = 1; k <= data.length * 2; k++) {
            available[k-1] = !dataSet.has(k);
        }

        let isValid = true;
        for (let i = 0; i < data.length; i++) {
            for (let r = data[i]; r <= available.length; r++) {
                if (available[r]) {
                    available[r] = false;
                    result.push(data[i]);
                    result.push(r+1);
                    break;
                } else if (r === available.length - 1 || r === available.length) {
                    return '-1';
                }
            }

        }

        return result.join(' ');

    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount*2].split(" ").map(Number);
        let result = foo(data);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})


Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size ai dollars.Each player can double his bid any number of times and triple his bid any number of times. The casino has a great jackpot for making all bids equal. Is it possible that Limak and his friends will win a jackpot?

First line of input contains an integer n (2 ≤ n ≤ 105), the number of players. The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109) — the bids of players.

Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.

NoteIn the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.It can be shown that in the second sample test there is no way to make all bids equal.

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = arr[0]
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(i / res)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = arr[0]
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    while (res % 6 === 0 && res != 1) res /= 6;
    while (res % 2 === 0 && res != 1) res /= 2;
    while (res % 3 === 0 && res != 1) res /= 3;
    //console.log(res)
    for (let i of arr) {
        let two = 1,
            three = 1
        while (i % (two * 2) === 0) two *= 2;
        while (i % (three * 3) === 0) three *= 3;
        //console.log(res * two * three, i)
        if (res * two * three != i) {
            console.log("No")
            return 0
        }
    }
    console.log("Yes")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

var n = +readline(), a = readline().split(" ").map(Number);
var check = true;

for(var i = 0; i < n; i++){
	for(;;){
		if(a[i] % 2 == 0){
			a[i] /= 2;
		}
		else{
			break;
		}
	}

	for(;;){
		if(a[i] % 3 == 0){
			a[i] /= 3;
		}
		else{
			break;
		}
	}
}

for(var i = 0; i < n-1; i++){
	if(a[i] != a[i+1]){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

var n = +readline(), arr = readline().split(" ").map(Number);
for(var i =0;i<n;i++)
{
    x = arr[i];
    while(x%2==0){x/=2;}
    while(x%3==0){x/=3;}
    arr[i]=x;
}
arr.sort();
if(arr[0]===arr[n-1])
{
    write('Yes');
}
else
{
    write('No');
}

// Generated by CoffeeScript 1.10.0
(function() {
  var a, gcd, n;

  n = parseInt(readline());

  a = readline().split(' ').map(function(item) {
    return parseInt(item);
  });

  gcd = null;

  (function() {
    var i, j, len, v;
    for (i = j = 0, len = a.length; j < len; i = ++j) {
      v = a[i];
      while (v % 2 === 0) {
        v /= 2;
      }
      while (v % 3 === 0) {
        v /= 3;
      }
      if (gcd == null) {
        gcd = v;
      } else if (gcd !== v) {
        print('No');
        return;
      }
    }
    return print('Yes');
  })();

}).call(this);

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const nok = (a, b) => a * b / gcd(a, b);

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = nok(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(res / i)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(i / res)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    while (res % 6 === 0 && res != 1) res /= 6;
    while (res % 2 === 0 && res != 1) res /= 2;
    while (res % 3 === 0 && res != 1) res /= 3;
    for (let i of arr) {
        let two = 1,
            three = 1
        while (i % (two * 2) === 0) two *= 2;
        while (i % (three * 3) === 0) three *= 3;
        if (res * two * three != i) {
            console.log("NO")
            return 0
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

for(i = 0; i < n; i++){
	if(a[i] == 1 || a[i] == 2 || a[i] == 3){
		a.splice(i,1);
	}
}

if(a.length == 0){
	write("Yes");
}
else if(a.length == 1){
	fact = factorization(a[0]);

	if(Object.keys(fact).length == 2){
		if(fact[2] == undefined && fact[3] == undefined){
			write("No");
		}
		else{
			write("Yes");
		}
	}
	else if(Object.keys(fact).length == 3){
		if(fact[2] && fact[3]){
			write("Yes");
		}
		else{
			write("Yes");
		}
	}
	else{
		write("No");
	}
}
else{
	nod = NOD(a);

	if(nod == 1){
		for(i = 0; i < a.length; i++){
			fact = factorization(a[i]);
			if(Object.keys(fact).length == 1){
				continue;
			}
			else if(Object.keys(fact).length == 2){
				if(fact[2] == undefined && fact[3] == undefined){
					write("No");
					check = false;
					break;
				}
				else{
					continue;
				}
			}
			else if(Object.keys(fact).length == 3){
				if(fact[2] && fact[3]){
					continue;
				}
				else{
					write("No");
					check = false;
					break;
				}
			}
			else{
				write("No");
				check = false;
				break;
			}
		}

		if(check){
			write("Yes");
		}
	}
	else{
		for(i = 0; i < a.length; i++){
			x = a[i] / nod;

			if(((x % 2) != 0) && ((x % 3) != 0)){
				write("No");
				check = false;
				break;
			}
		}

		if(check){
			write("Yes");
		}
	}
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true;

nod = NOD(a);

for(i = 0; i < n; i++){
	x = a[i] / nod;

	if(x == 1){
		continue;
	}

	if(((x % 2) != 0) && ((x % 3) != 0)){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		fact = factorization(a[i]);
		if(Object.keys(fact).length == 1){
			continue;
		}
		else if(Object.keys(fact).length == 2){
			if(fact[2] == undefined || fact[3] == undefined){
				write("No");
				check = false;
				break;
			}
			else{
				continue;
			}
		}
		else if(Object.keys(fact).length == 3){
			if(fact[2] && fact[3]){
				continue;
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
		else{
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true;

nod = NOD(a);

for(i = 0; i < n; i++){
	x = a[i] / nod;

	if(((x % 2) != 0) && ((x % 3) != 0)){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		fact = factorization(a[i]);
		if(Object.keys(fact).length == 1){
			continue;
		}
		else if(Object.keys(fact).length == 2){
			if(fact[2] == undefined && fact[3] == undefined){
				write("No");
				check = false;
				break;
			}
			else{
				continue;
			}
		}
		else if(Object.keys(fact).length == 3){
			if(fact[2] && fact[3]){
				continue;
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
		else{
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		if(a[i] == 2 || a[i] == 3){
			continue;
		}
		else{
			fact = factorization(a[i]);
			if(Object.keys(fact).length == 2){
				if(fact[2] == undefined || fact[3] == undefined){
					write("No");
					check = false;
					break;
				}
				else{
					continue;
				}
			}
			else if(Object.keys(fact).length == 3){
				if(fact[2] && fact[3]){
					continue;
				}
				else{
					write("No");
					check = false;
					break;
				}
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

var n = +readline(), a = readline().split(" ").map(Number);
var check = true;

for(var i = 0; i < n; i++){
	for(;;){
		if(a[i] % 2 == 0){
			a[i] /= 2;
		}
		else{
			break;
		}
	}

	for(;;){
		if(a[i] % 3 == 0){
			a[i] /= 3;
		}
		else{
			break;
		}
	}
}

for(var i = 0; i < n-1; i++){
	if(a[i] != a[i+1]){
		write("No");
		check = false;
	}
}

if(check){
	write("Yes");
}

// Generated by CoffeeScript 1.10.0
(function() {
  var a, gcd, n;

  n = parseInt(readline());

  a = readline().split(' ').map(function(item) {
    return parseInt(item);
  });

  gcd = null;

  (function() {
    var i, j, len, v;
    for (i = j = 0, len = a.length; j < len; i = ++j) {
      v = a[i];
      while (v % 2 === 0) {
        v /= 2;
      }
      while (v % 3 === 0) {
        v /= 3;
      }
      if (gcd == null) {
        gcd = v;
      } else if (gcd !== v) {
        print('No');
        return;
      }
      print(v);
    }
    return print('Yes');
  })();

}).call(this);


Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point $$$T$$$, which coordinates to be found out.Bob travelled around the world and collected clues of the treasure location at $$$n$$$ obelisks. These clues were in an ancient language, and he has only decrypted them at home. Since he does not know which clue belongs to which obelisk, finding the treasure might pose a challenge. Can you help him?As everyone knows, the world is a two-dimensional plane. The $$$i$$$-th obelisk is at integer coordinates $$$(x_i, y_i)$$$. The $$$j$$$-th clue consists of $$$2$$$ integers $$$(a_j, b_j)$$$ and belongs to the obelisk $$$p_j$$$, where $$$p$$$ is some (unknown) permutation on $$$n$$$ elements. It means that the treasure is located at $$$T=(x_{p_j} + a_j, y_{p_j} + b_j)$$$. This point $$$T$$$ is the same for all clues.In other words, each clue belongs to exactly one of the obelisks, and each obelisk has exactly one clue that belongs to it. A clue represents the vector from the obelisk to the treasure. The clues must be distributed among the obelisks in such a way that they all point to the same position of the treasure.Your task is to find the coordinates of the treasure. If there are multiple solutions, you may print any of them.Note that you don't need to find the permutation. Permutations are used only in order to explain the problem.

The first line contains an integer $$$n$$$ ($$$1 \leq n \leq 1000$$$) — the number of obelisks, that is also equal to the number of clues. Each of the next $$$n$$$ lines contains two integers $$$x_i$$$, $$$y_i$$$ ($$$-10^6 \leq x_i, y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th obelisk. All coordinates are distinct, that is $$$x_i \neq x_j$$$ or $$$y_i \neq y_j$$$ will be satisfied for every $$$(i, j)$$$ such that $$$i \neq j$$$.  Each of the next $$$n$$$ lines contains two integers $$$a_i$$$, $$$b_i$$$ ($$$-2 \cdot 10^6 \leq a_i, b_i \leq 2 \cdot 10^6$$$) — the direction of the $$$i$$$-th clue. All coordinates are distinct, that is $$$a_i \neq a_j$$$ or $$$b_i \neq b_j$$$ will be satisfied for every $$$(i, j)$$$ such that $$$i \neq j$$$.  It is guaranteed that there exists a permutation $$$p$$$, such that for all $$$i,j$$$ it holds $$$\left(x_{p_i} + a_i, y_{p_i} + b_i\right) = \left(x_{p_j} + a_j, y_{p_j} + b_j\right)$$$.

Output a single line containing two integers $$$T_x, T_y$$$ — the coordinates of the treasure. If there are multiple answers, you may print any of them.

NoteAs $$$n = 2$$$, we can consider all permutations on two elements. If $$$p = [1, 2]$$$, then the obelisk $$$(2, 5)$$$ holds the clue $$$(7, -2)$$$, which means that the treasure is hidden at $$$(9, 3)$$$. The second obelisk $$$(-6, 4)$$$ would give the clue $$$(-1,-3)$$$ and the treasure at $$$(-7, 1)$$$. However, both obelisks must give the same location, hence this is clearly not the correct permutation.If the hidden permutation is $$$[2, 1]$$$, then the first clue belongs to the second obelisk and the second clue belongs to the first obelisk. Hence $$$(-6, 4) + (7, -2) = (2,5) + (-1,-3) = (1, 2)$$$, so $$$T = (1,2)$$$ is the location of the treasure.  In the second sample, the hidden permutation is $$$[2, 3, 4, 1]$$$.

//var input = readline()
var t = parseInt(readline());

var x = 0, y = 0;
for(var i=0; i<t*2; i++) {
    var ar = readline().split(' ').map(x => parseInt(x));
    var a = ar[0], b = ar[1];
    x += a , y += b;
}
print(x/t  +' '+  y/t);

//

//var input = readline()
var t = readline()

var x = 0, y = 0
for(var i=0; i<t; i++) {
    var ar = readline().split(' ')
    var a = ar[0]
    var b = ar[1]
    x += parseInt(a)
    y += parseInt(b)
}
//print(x +' '+ y)

var x2 = 0, y2 = 0
for(var i=0; i<t; i++) {
    var arr = readline().split(' ')
    var c = arr[0]
    var d = arr[1]
    x2 += parseInt(c)
    y2 += parseInt(d)
}
//print(x2 +' '+ y2)

print((x+x2)/t  +' '+  (y+y2)/t)

//var input = readline()
var t = readline()

var x = 0, y = 0
for(var i=0; i<t*2; i++) {
    var ar = readline().split(' ')
    var a = ar[0]
    var b = ar[1]
    x += parseInt(a)
    y += parseInt(b)
}
print(x/t  +' '+  y/t)

const rl = require('readline')

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

let n, obelisks = [], clues = [], numLines = 0
readline.on('line', line => {
	if (numLines == 0) {
		n = parseInt(line)
	} else {
		const coordinate = line.split(' ').map(Number);
		[obelisks, clues][numLines > n ? 1 : 0].push({
			x: coordinate[0],
			y: coordinate[1]
		})
	}
	numLines++
}).on('close', () => {
	const p = obelisks.sort((a, b) => a.x - b.x || a.y - b.y).shift()
	const q = clues.sort((a, b) => b.x - a.x || b.y - a.y).shift()
	console.log(`${p.x + q.x} ${p.y + q.y}`)
})

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity:
// Space complexity:

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

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (numberOfObelisks) {
        const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
        if (isReadingObelisksCoordinates) {
            obelisksCoordinates.push(getCoordinate(input));
        } else {
            cluesCoordinates.push(getCoordinate(input));
        }
    } else {
        numberOfObelisks = parseInt(input);
    }

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x}, ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesDictionary = getCluesDictionary(cluesCoordinates);

    for (let clue of cluesCoordinates) {
        const firstObelisk = obelisksCoordinates[0];
        const treasure = firstObelisk.addCoordinate(clue);
        const treasureFound = treasureMatch(treasure, obelisksCoordinates, cluesDictionary);
        if (treasureFound) {
            return `${treasure.x} ${treasure.y}`;
        }
    }

    return "";
}

function treasureMatch(treasure, obelisksCoordinates, cluesDictionary) {
    for (let obelisk of obelisksCoordinates) {
        const x = treasure.x - obelisk.x;
        const y = treasure.y - obelisk.y;

        const possibleClue = new Coordinate(x, y);
        if (cluesDictionary[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}

function getCluesDictionary(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

// console.log(findTreasure([new Coordinate(2, 5), new Coordinate(-6, 4)], [new Coordinate(7, -2), new Coordinate(-1, -3)]))

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity: O(n^2)
// Space complexity: O(n)

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

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (!numberOfObelisks) {
        numberOfObelisks = parseInt(input);
        return;
    }

    readCoordinates(input);

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function readCoordinates(input) {
    const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
    if (isReadingObelisksCoordinates) {
        obelisksCoordinates.push(getCoordinate(input));
    } else {
        cluesCoordinates.push(getCoordinate(input));
    }
}

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x} ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesIndexes = getCluesIndexes(cluesCoordinates);
    const firstObelisk = obelisksCoordinates[0];

    for (let clue of cluesCoordinates) {
        const treasureCoordinate = firstObelisk.addCoordinate(clue);
        const treasureFound = isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes);
        if (treasureFound) {
            return treasureCoordinate.toString();
        }
    }

    return "";
}

function getCluesIndexes(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

function isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes) {
    for (let obelisk of obelisksCoordinates) {
        // Check if there is a clue that points to the treasure for the current obelisk
        const x = treasureCoordinate.x - obelisk.x;
        const y = treasureCoordinate.y - obelisk.y;
        const possibleClue = new Coordinate(x, y);
        if (cluesIndexes[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity: O(n^2)
// Space complexity: O(n)

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

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (!numberOfObelisks) {
        numberOfObelisks = parseInt(input);
        return;
    }

    readCoordinates(input);

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function readCoordinates(input) {
    const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
    if (isReadingObelisksCoordinates) {
        obelisksCoordinates.push(getCoordinate(input));
    } else {
        cluesCoordinates.push(getCoordinate(input));
    }
}

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x} ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesIndexes = getCluesIndexes(cluesCoordinates);
    const firstObelisk = obelisksCoordinates.shift();

    for (let clue of cluesCoordinates) {
        const treasureCoordinate = firstObelisk.addCoordinate(clue);
        const treasureFound = isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes);
        if (treasureFound) {
            return treasureCoordinate.toString();
        }
    }

    return "";
}

function getCluesIndexes(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

function isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes) {
    for (let obelisk of obelisksCoordinates) {
        // Check if there is a clue that points to the treasure for the current obelisk
        const x = treasureCoordinate.x - obelisk.x;
        const y = treasureCoordinate.y - obelisk.y;
        const possibleClue = new Coordinate(x, y);
        if (cluesIndexes[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}