var n = readline();
var x = readline().split(" ");
var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    if(x[i] > 0)
        nPositive++;
    if(x[i] < 0)
        nNegative++;
}

if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

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

let l = 0;
let n = 0

rl.on('line', (input) => {
    if (l === 0) {
        n = parseInt(input)
    } else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        for (let i = 1; i <= 1000; i++) {
            let p = 0;
            for (let j = 0; j < n; j++) {
                if ((arr[j] / i) > 0) {
                    p++
                }
            }
            if (p >= Math.ceil(n / 2)) {
                console.log(i)
                return
            }

            p = 0;
            for (let j = 0; j < n; j++) {
                if (arr[j] / (i * -1) > 0) {
                    p++
                }
            }
            if (p >= Math.ceil(n / 2)) {
                console.log(i * -1)
                return
            }
        }

        console.log(0)
        return
    }
    l++
});

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

var inputs = [];
const PI = parseInt;

function main() {
    pos = inputs[1].split(" ").filter(_ => PI(_) > 0);
    neg = inputs[1].split(" ").filter(_ => PI(_) < 0);

    const ln = inputs[1].split(" ").length;
    if(pos.length >= ln / 2) console.log(1);
    else if(neg.length >= ln / 2) console.log(-1);
    else console.log(0)
}

readline.on('line', (input) => { inputs.push(input); });
readline.on('close', main)

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

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var plus = 0;
  var minus = 0;
  var zero = 0;
  for(var i = 0; i < N; i++){
    if(list[i] < 0){
      minus++;
    }else if(list[i] > 0){
      plus++;
    }else{
      zero++;
    }
  }
  if(minus >= N / 2){
    myout(-1);
  }else if(plus >= N / 2){
    myout(1);
  }else{
    myout(0);
  }
}

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

let c = 0;

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

  let pos = 0;
  let neg = 0;
  const arr = d.split(" ").map(Number);
  let min = Math.ceil(arr.length / 2);

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

  if (pos >= min) {
    console.log(1);
  } else if (Math.abs(neg) >= min) {
    console.log(-1);
  } else {
    console.log(0);
  }
  c++;
});

let rawInput = '';
process.stdin.on('data', c => rawInput += c);
let inputByLinesOnRslv = new Promise((resolve, reject) => {
    process.stdin.on('end', () => {
        const { EOL } = require('os');
        resolve(rawInput.split(EOL));
    });
});

(async function(){

    let lines = await inputByLinesOnRslv;
    let n = parseInt(lines[0]);
    let items = lines[1].split(" ");
    let ls = parseFloat(n) / 2.0;
    let found = 0;

    for (let d = -1000; d <= 1000; ++d) {
        if (!d) { continue; }
        let many = 0;
        for (let i = 0; i < n; ++i) {
            let curd = parseFloat(items[i]) / parseFloat(d);
            if (curd > 0) { many++; }
        }
        if (many < ls) { continue; }
        found = 1;
        console.log(d);
        break;
    }
    if (!found) { console.log(0); }

})();

let rawInput = '';
process.stdin.on('data', c => rawInput += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = rawInput.split(EOL);
    let n = parseInt(lines[0]);
    let items = lines[1].split(" ");
    //console.log(items);
    let ls = parseFloat(n) / 2.0;
    //console.log(ls);
    let found = 0;
    for (let d = -1000; d <= 1000; ++d) {
        if (!d) { continue; }
        let many = 0;
        for (let i = 0; i < n; ++i) {
            let curd = 0.0;
            curd = parseFloat(items[i]) / parseFloat(d);
            //console.log(curd);
            if (curd > 0) { many++; }
        }
        if (many < ls) { continue; }
        found = 1;
        console.log(d);
        break;
    }
    if (!found) { console.log(0); }
});

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

var inputs = [];
const PI = parseInt;

function main() {
    pos = inputs[1].split(" ").filter(_ => PI(_) > 0);
    neg = inputs[1].split(" ").filter(_ => PI(_) < 0);

    const ln = inputs[1].split(" ").length;
    if(pos > ln / 2) console.log(1);
    else if(neg > ln / 2) console.log(-1);
    else console.log(0)
}

readline.on('line', (input) => { inputs.push(input); });
readline.on('close', main)

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

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var plus = 0;
  var minus = 0;
  var zero = 0;
  for(var i = 0; i < N; i++){
    if(list[i] < 0){
      minus++;
    }else if(list[i] > 0){
      plus++;
    }else{
      zero++;
    }
  }
  if(minus > zero && minus > plus){
    myout(-1);
  }else if(plus > zero && plus > minus){
    myout(1);
  }else{
    myout(0);
  }
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var plus = 0;
  var minus = 0;
  var zero = 0;
  for(var i = 0; i < N; i++){
    if(list[i] < 0){
      minus++;
    }else if(list[i] > 0){
      plus++;
    }else{
      zero++;
    }
  }
  if(minus > N / 2){
    myout(-1);
  }else if(plus > N / 2){
    myout(1);
  }else{
    myout(0);
  }
}

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

let c = 0;

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

  let ans = 0;
  const arr = d.split(" ").map(Number);
  let min = Math.ceil(arr.length / 2);

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

  if (ans >= min) {
    console.log(1);
  } else {
    console.log(0);
  }
  c++;
});

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

let c = 0;

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

  let ans = 0;
  const arr = d.split(" ").map(Number);
  let min = Math.ceil(arr.length / 2);

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

  if (ans >= min) {
    console.log(ans);
  } else {
    console.log(0);
  }
  c++;
});

var n = readline();
var x;
var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    x = readline();
    print(x);

    if(x > 0)
        nPositive++;
    if(x < 0)
        nNegative--;
}
print(number);
print(nPositive);
print(nNegative);
if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

var n = readline();
var x;
var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    x = readline();

    if(x > 0)
        nPositive++;
    if(x < 0)
        nNegative++;
}

if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

var n = readline();

var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    var x = readline();

    if(x > 0)
        nPositive++;
    if(x < 0)
        nNegative--;
}

if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

var n = readline();

var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    var x;
    x = readline();

    if(x > 0)
    {
        nPositive++;
        print("hello");
    }

    if(x < 0)
        nNegative--;
}
print(number);
print(nPositive);
print(nNegative);
if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

var n = readline();

var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    var x;
    x = readline();
    print(x);

    if(x > 0)
        nPositive++;
    if(x < 0)
        nNegative--;
}
print(number);
print(nPositive);
print(nNegative);
if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

var n = readline();

var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    var x;
    x = readline();

    if(x > 0)
        nPositive++;
    if(x < 0)
        nNegative--;
}
print(number);
print(nPositive);
print(nNegative);
if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

var n = readline();

var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    var x;
    x = readline();

    if(x > 0)
        nPositive++;
    if(x < 0)
        nNegative--;
}

if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);

var n = readline();

var nPositive = 0;
var nNegative = 0;

number = Math.ceil(n / 2);

for(var i = 0; i < n; i++)
{
    var x = readline();
    print(x);

    if(x > 0)
        nPositive++;
    if(x < 0)
        nNegative--;
}
print(number);
print(nPositive);
print(nNegative);
if(nPositive >= number)
    print(1);
else if(nNegative >= number)
    print(-1);
else
    print(0);


var xParams = readline().split(' '),
    xRepresentation = readline();
    yParams = readline().split(' '),
    yRepresentation = readline();

// var xParams = "7 16".split(' '),
//     xRepresentation = "15 15 4 0 0 7 10";
//     yParams = "7 9".split(' '),
//     yRepresentation = "4 8 0 3 1 5 0";

var n = Number(xParams[0]),
    xNumSys = Number(xParams[1]),
    m = Number(yParams[0]),
    yNumSys = Number(yParams[1]);

function solver() {
    var x = transformBaseRepToDecimal(xRepresentation.split(' ').map(function (item) {
        return Number(item);
    }), xNumSys);
    var y = transformBaseRepToDecimal(yRepresentation.split(' ').map(function (item) {
        return Number(item);
    }), yNumSys);

    var res = '=';
    if (x < y) {
        return '<';
    } else if (x > y) {
        return '>';
    }

    return res;
}

function transformBaseRepToDecimal(arr, base) {
    var decimalValue = 0;

    for (var i = arr.length - 1, val = 1; i >= 0; i--) {
        decimalValue += ((val * arr[i]));
        val *= base;
    }

    return decimalValue;
}

print(solver());
// console.log(solver());

var x = readline().split(' ');
var n = parseInt(x[0]);
var bx = parseInt(x[1]);
x = readline().split(' ');
var a = []
for(var i = 0; i < n; i++) {
    a[i] = parseInt(x[i]);
}
x = readline().split(' ');
var m = parseInt(x[0]);
var by = parseInt(x[1]);
x = readline().split(' ');
var b = []
for(var i = 0; i<m;i ++) {
    b[i] = parseInt(x[i]);
}
var a1 = 0;
for(var i=0;i<n;i++) {
    a1 = a1 * bx + a[i];
}
var a2 = 0;
for(var i = 0; i < m; i ++) {
    a2 = a2 * by + b[i];
}
if(a1 < a2) print("<");
else if(a1 == a2) print("=");
else print(">");

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return +readline(); }

var inp = rda();
var n = inp[0], bx = inp[1];
var x = rda();
inp = rda();
var m = inp[0], by = inp[1];
var y = rda();

var x10 = 0, y10 = 0;

var pows = [];
for(var i = 0, s = 1; i < n; i++, s *= bx){
    pows.push(s);
}
pows.reverse();
for(var i = 0; i < n; i++){
    x10 += pows[i]*x[i];
}

pows = [];
for(var i = 0, s = 1; i < m; i++, s *= by){
    pows.push(s);
}
pows.reverse();
for(var i = 0; i < m; i++){
    y10 += pows[i]*y[i];
}

if(x10 == y10){
    write("=");
}else if(x10 > y10){
    write(">");
}else{
    write("<");
}


var input = readline().split(' ').map(Number);

var month = input[0];
var firstday = input[1];

var month_days = 0;

if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
	month_days = 31;
} else if (month == 2) {
	month_days = 28;
} else {
	month_days = 30;
}

var wasted_days = (firstday - 1) % 7;

var total_days = wasted_days + month_days;

var weeks = Math.ceil(total_days / 7);

print(weeks);

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

const daysInMonth = (month) => new Date(2017, month, 0).getDate();

rl.on('line', (data) => {
  const [m, d] = data.split(' ').map(Number);
  const days = daysInMonth(m);
  const ans = Math.ceil((days + (d - 1)) / 7);

  console.log(ans);
});

var m, d, out;

m=readline().split(' ')
d=parseInt(m[1])
m=parseInt(m[0])

out=(d==7)?6:5;

switch (m){
    case 2: out=(d==1)?4:5; break;
    case 1: out=(d==6)?6:out; break;
    case 3: out=(d==6)?6:out; break;
    case 5: out=(d==6)?6:out; break;
    case 7: out=(d==6)?6:out; break;
    case 8: out=(d==6)?6:out; break;
    case 10: out=(d==6)?6:out; break;
    case 12: out=(d==6)?6:out; break;
}

print (out)

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

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

let nl = nextLine();

nl.num = function() {
		return Number(this.next().value);
	};
nl.nums = function() {
		return this.next().value.split(/\s/g).map(Number);
	};
nl.line = function() {
		return this.next().value;
	}

const sol = () => {
	let [m, d] = nl.nums();
	let month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	console.log(Math.trunc((d - 1 + month[m-1] + 6)/7));

};

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

var input = readline().split(' ').map(Number);

var month = input[0];
var firstday = input[1];

var month_days = 0;

if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
	month_days = 31;
} else if (month == 2) {
	month_days = 29;
} else {
	month_days = 30;
}

var wasted_days = (firstday - 1) % 7;

var total_days = wasted_days + month_days;

var weeks = Math.ceil(total_days / 7);

print(weeks);

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

const daysInMonth = (month) => new Date(2017, month, 0).getDate();

rl.on('line', (data) => {
  const [m, d] = data.split(' ').map(Number);
  const days = daysInMonth(m);
  const ans = Math.ceil((days + d - (7 - d)) / 7);

  console.log(ans);
});

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

const daysInMonth = (month) => new Date(2017, month, 0).getDate();

rl.on('line', (data) => {
  const [m, d] = data.split(' ').map(Number);
  const days = daysInMonth(m);
  const ans = Math.ceil(days / 7);

  console.log(ans);
});


var n = parseInt(readline()),
    found = false

//console.log('n',n)
for (var m = 1 ; m < 1000 && !found ; m++) {
  var res = n * m + 1
  //console.log("a",m,res,Math.sqrt(res))
  for (var div = 2 ; div <= Math.sqrt(res) && !found ; div++) {
    //console.log("b",m)
    //console.log(m,res,div,res%div)
    if (!(res%div)) found = m
  }
}

print(found)

function isPrime(temp) {
	for (var j = 2; j * j <= temp; j++) {
		if (temp % j === 0) {
			return true;
		}
	}
}
var n = Number(readline()), result;
for (var i = 1; ; i++) {
	var temp = n * i + 1;
	if (isPrime(temp)) {
	    result = i;
		break;
	}
}
print(result);

var n = parseInt(readline());
for (var m = 1; m <= 1000; m++) {
    var theoreticResult = n * m + 1;
    if (isPrime(theoreticResult)) {
        print(m);
        break;
    }
}

function isPrime(n) {
    for (var i = 2; i <= Math.sqrt(n); i++) {
        if (n % i === 0) {
            return true;
        }
    }

    return false;
}

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

	if (n == 1) {
		print(3);
	} else if (n == 2) {
		print(4);
	} else {
		print(n - 2);
	}

	return 0;
}

main();

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

const isPrime = (n) => {
  for (let i = 2; i*i <= n; i++) {
    if (n % i === 0) {
      return false;
    }
  }

  return true;
}

rl.on('line', (d) => {
  let ans = 1;

  while (isPrime(+d * ans + 1)) {
    ans++;
  }

  console.log(ans);
});

function is_prime(n){
        for (var i=2;i*i<=n;i++)
            if (n%i==0)
                return false;
        return true;
    }
    var n = +readline();
    for (var m = 1;; m++)
        if (!is_prime(n*m+1))
        {
            print(m);
            break;
        }

var n = readline(),
lastDigit = Number(n[n.length - 1]),
secondToLastDigit = n.length >= 2 ? Number(n[n.length - 2]) : 0,
severalLastDigits = secondToLastDigit * 10 + lastDigit,
result;
if (severalLastDigits === 0) {
	severalLastDigits = Number(/[1-9]0+$/.exec(n)[0]);
}
for (var i = 1; ; i++) {
	var temp = severalLastDigits * i + 1;
	if (temp % 2 === 0 && temp != 2 || temp % 3 === 0 && temp != 3  ||
		temp % 5 === 0 && temp != 5 || temp % 7 === 0 && temp != 7 ) {
		result = i;
		break;
	}
}
print(result);


const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  solve(a, b)
})

function solve(a, b) {
 if (a == b) { console.log(0); return; }

 const m = {}
 if (b > a) {
  const t = a; a = b; b = t;
 }
 const ma = { [a]: 0 }
 const mb = { [b]: 0 }

 const qa = [[a, 0]]
 const qb = [[b, 0]]

 let min = Infinity;
 while (true) {
  if (qa.length) {
  const [aa, sa] = qa.shift()

  for (const d of [2,3,5]) {
   if (aa%d == 0) {
     const r = aa/d
     if (mb[r] != undefined) { min = Math.min(mb[r]+sa+1, min); }
     if (!ma[r]) { qa.push([r, sa+1]) }
     ma[r] = ma[r] || (sa+1);
   }
  }
 }

 if (qb.length) {

  const [bb, sb] = qb.shift()
  for (const d of [2,3,5]) {
   if (bb%d == 0) {
     const r = bb/d
     if (ma[r] != undefined) { min = Math.min(ma[r]+sb+1, min); }
     if (!mb[r]) { qb.push([r, sb+1]) }
     mb[r] = mb[r] || (sb+1);
   }
  }
 }

 if (isFinite(min)) { console.log(min); return; }

  if (!qa.length && !qb.length) { console.log(-1); return; }

 }
}

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

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

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

function descendA(hash, a, steps) {
	if (hash[a] !== undefined && hash[a] <= steps) {
		return;
	}
	hash[a] = steps;
	if (a%2 == 0) {
		descendA(hash, a/2, steps+1);
	}
	if (a%3 == 0) {
		descendA(hash, a/3, steps+1);
	}
	if (a%5 == 0) {
		descendA(hash, a/5, steps+1);
	}
}

function descendB(hashA, hashB, b, steps, best) {
	if (hashB[b] !== undefined && hashB[b] <= steps) {
		return;
	}
	hashB[b] = steps;
	if (hashA[b] !== undefined) {
		if (best.value == -1 || hashA[b]+steps < best.value) {
			best.value = hashA[b]+steps;
		}
	}
	if (b%2 == 0) {
		descendB(hashA, hashB, b/2, steps+1, best);
	}
	if (b%3 == 0) {
		descendB(hashA, hashB, b/3, steps+1, best);
	}
	if (b%5 == 0) {
		descendB(hashA, hashB, b/5, steps+1, best);
	}
}

function main() {
	var integers = tokenizeIntegers(readline());
	var a = integers[0], b = integers[1];

	var hashA = {};
	descendA(hashA, a, 0);

	var hashB = {};
	var best = {value: -1};
	descendB(hashA, hashB, b, 0, best);

	print(best.value);
}

main();

const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  solve(a, b)
})

function solve(a, b) {
 if (a == b) { console.log(0); return; }

 const m = {}
 if (b > a) {
  const t = a; a = b; b = t;
 }
 const ma = { [a]: 0 }
 const mb = { [b]: 0 }

 const qa = [[a, 0]]
 const qb = [[b, 0]]

 let min = Infinity;
 while (true) {
  if (qa.length) {
  const [aa, sa] = qa.shift()

  for (const d of [2,3,5]) {
   if (aa%d == 0) {
     const r = aa/d
     if (mb[r]) { min = Math.min(mb[r]+sa+1, min); }
     if (!ma[r]) { qa.push([r, sa+1]) }
     ma[r] = ma[r] || (sa+1);
   }
  }
 }

 if (qb.length) {

  const [bb, sb] = qb.shift()
  for (const d of [2,3,5]) {
   if (bb%d == 0) {
     const r = bb/d
     if (ma[r]) { min = Math.min(ma[r]+sb+1, min); }
     if (!mb[r]) { qb.push([r, sb+1]) }
     mb[r] = mb[r] || (sb+1);
   }
  }
 }

 if (isFinite(min)) { console.log(min); return; }

  if (!qa.length && !qb.length) { console.log(-1); return; }

 }
}

const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  solve(a, b)
})

function solve(a, b) {
 if (a == b) return 0

 const m = {}
 if (b > a) {
  const t = a; a = b; b = t;
 }
 const ma = { [a]: 0 }
 const mb = { [b]: 0 }

 const qa = [[a, 0]]
 const qb = [[b, 0]]

 let iter = 0;
 while (true) {
  if (!qa.length && !qb.length) { console.log(-1); return; }
  const [aa, sa] = qa.shift()

  for (const d of [2,3,5]) {
   if (aa%d == 0) {
     const r = aa/d
     if (mb[r]) { console.log(mb[r]+sa+1); return; }
     if (!ma[r]) { qa.push([r, sa+1]) }
     ma[r] = ma[r] || (sa+1);
   }
  }

 if (!qb.length) { continue; }

  const [bb, sb] = qb.shift()
  for (const d of [2,3,5]) {
   if (bb%d == 0) {
     const r = bb/d
     if (ma[r]) { console.log(ma[r]+sb+1); return; }
     if (!mb[r]) { qb.push([r, sb+1]) }
     mb[r] = mb[r] || (sb+1);
   }
  }

  if (!qa.length) { console.log(-1); return; }

 }
}

const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  solve(a, b)
})

function solve(a, b) {
 if (a == b) return 0

 const m = {}
 if (b > a) {
  const t = a; a = b; b = t;
 }
 const ma = { [a]: 0 }
 const mb = { [b]: 0 }

 const qa = [[a, 0]]
 const qb = [[b, 0]]

 let iter = 0;
 while (true) {
  const [aa, sa] = qa.shift()

  for (const d of [2,3,5]) {
   if (aa%d == 0) {
     const r = aa/d
     if (mb[r]) { console.log(mb[r]+sa+1); return; }
     if (!ma[r]) { qa.push([r, sa+1]) }
     ma[r] = ma[r] || (sa+1);
   }
  }

 if (!qb.length) { console.log(-1); return; }

  const [bb, sb] = qb.shift()
  for (const d of [2,3,5]) {
   if (bb%d == 0) {
     const r = bb/d
     if (ma[r]) { console.log(ma[r]+sb+1); return; }
     if (!mb[r]) { qb.push([r, sb+1]) }
     mb[r] = mb[r] || (sa+1);
   }
  }

  if (!qa.length) { console.log(-1); return; }

 }
}

const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  solve(a, b)
})

function solve(a, b) {
 if (a == b) return 0

 const m = {}
 if (b > a) {
  const t = a; a = b; b = t;
 }
 const ma = { [a]: 0 }
 const mb = { [b]: 0 }

 const qa = [[a, 0]]
 const qb = [[b, 0]]

 let iter = 0;
 while (true) {
  const [aa, sa] = qa.shift()

  for (const d of [2,3,5]) {
   if (aa%d == 0) {
     const r = aa/d
     if (mb[r]) { console.log(mb[r]+sa+1); return; }
     if (!ma[r]) { qa.push([r, sa+1]) }
     ma[r] = ma[r] || (sa+1);
   }
  }

 if (!qb.length) { console.log(-1); return; }

  const [bb, sb] = qb.shift()
  for (const d of [2,3,5]) {
   if (bb%d == 0) {
     const r = bb/d
     if (ma[r]) { console.log(ma[r]+sb+1); return; }
     if (!mb[r]) { qb.push([r, sb+1]) }
     mb[r] = mb[r] || (sb+1);
   }
  }

  if (!qa.length) { console.log(-1); return; }

 }
}

const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  solve(a, b)
})

function solve(a, b) {
 if (a == b) { console.log(0); return; }

 const m = {}
 if (b > a) {
  const t = a; a = b; b = t;
 }
 const ma = { [a]: 0 }
 const mb = { [b]: 0 }

 const qa = [[a, 0]]
 const qb = [[b, 0]]

 let iter = 0;
 while (true) {
  if (qa.length) {
  const [aa, sa] = qa.shift()

  for (const d of [2,3,5]) {
   if (aa%d == 0) {
     const r = aa/d
     if (mb[r]) { console.log(mb[r]+sa+1); return; }
     if (!ma[r]) { qa.push([r, sa+1]) }
     ma[r] = ma[r] || (sa+1);
   }
  }
 }

 if (qb.length) {

  const [bb, sb] = qb.shift()
  for (const d of [2,3,5]) {
   if (bb%d == 0) {
     const r = bb/d
     if (ma[r]) { console.log(ma[r]+sb+1); return; }
     if (!mb[r]) { qb.push([r, sb+1]) }
     mb[r] = mb[r] || (sb+1);
   }
  }
 }

  if (!qa.length && !qb.length) { console.log(-1); return; }

 }
}


function main() {

    var input1= readline().split(' ').map(Number);

    var arr = readline().split(' ').map(Number);

    var n=input1[0];
    var temparr=arr.slice();
    var sortarr=temparr.sort(function(a, b){return a-b});
    var newarr=[];
    var result=[];
    var col=0;
    var res;

    for(var i=0;i<n;i++){
        if(i%2===0){
            col=0;
        }else {
            col=1;
        }
        var temp=[sortarr[i],col];
        newarr.push(temp);
    }

    for(var j=0;j<n;j++){
        for(var k=0;k<n;k++) {
            if (arr[j] === newarr[k][0]) {
                result.push(newarr[k][1]);
            }
        }
    }

    res=result.join(" ");
    print(res);

}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function sortNumber(a, b) {
    return a - b;
}

function main() {
    var n = nextInt();
    var m = nextInt();
    var arr = [];
    var pos = [];
    var r = [];
    for (var i = 0; i < 101; i++) {
        r[i] = -1;
    }
    for (var i = 0; i < n; i++) {
        arr[i] = nextInt();
        pos[arr[i]] = i;
    }
    for (var i = 0; i < m; i++) {
        var x = nextInt();
        var y = nextInt();
    }
    var s = "";
    arr.sort(sortNumber);
    for (var i = 0; i < n; i++) {
        r[pos[arr[i]]] = i % 2;
    }
    for (var i = 0; i < 101; i++) {
        if (r[i] != -1) {
            s += r[i] + " ";
        }
    }
    print(s);
}

main();

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

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

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

function main() {
	var data = tokenizeIntegers(readline()),
		pointNum = data[0], segmentNum = data[1],
		points = tokenizeIntegers(readline());
	for (var i = 0; i < segmentNum; ++i) {
		data = tokenizeIntegers(readline());
	}
	var pointInfo = [];
	for (var i = 0; i < pointNum; ++i) {
		pointInfo.push({ index: i, value: points[i] });
	}
	pointInfo.sort(function(a, b) {
		return a.value - b.value;
	});
	var result = new Array(pointNum);
	for (var i = 0; i < pointNum; ++i) {
		result[pointInfo[i].index] = i%2;
	}
	print(result.join(' '));
}

main();

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

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

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

function main() {
	var data = tokenizeIntegers(readline()),
		pointNum = data[0], segmentNum = data[1],
		points = tokenizeIntegers(readline()),
		segments = [],
		colors = new Array(101);
	for (var i = 0; i < colors.length; ++i) {
		colors[i] = 0;
	}
	for (var i = 0; i < pointNum; ++i) {
		colors[points[i]] = (i%2 == 0 ? -1 : 1);
	}
	for (var i = 0; i < segmentNum; ++i) {
		data = tokenizeIntegers(readline());
		segments.push({ left: data[0], right: data[1] });
	}
	for (var i = 0; i < segmentNum; ++i) {
		var segment = segments[i],
			count = 0;
		for (var j = segment.left; j <= segment.right; ++j) {
			count += colors[j];
		}
		if (count < -1 || count > 1) {
			print(-1);
			return;
		}
	}
	var result = [];
	for (var i = 0; i < pointNum; ++i) {
		result.push(i%2);
	}
	print(result.join(' '));
}

main();

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

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

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

function main() {
	var data = tokenizeIntegers(readline()),
		pointNum = data[0], segmentNum = data[1],
		points = tokenizeIntegers(readline());
	for (var i = 0; i < segmentNum; ++i) {
		data = tokenizeIntegers(readline());
	}
	var result = [];
	for (var i = 0; i < pointNum; ++i) {
		result.push(i%2 == 0 ? 1 : 0);
	}
	print(result.join(' '));
}

main();

function main() {

    var input1= readline().split(' ').map(Number);

    var arr = readline().split(' ').map(Number);

    var n=input1[0];
    var temparr=arr.slice();
    var sortarr=temparr.sort(function(a, b){return a-b});
    var newarr=[];
    var result=[];
    var col=0;

    for(var i=0;i<n;i++){
        if(i%2===0){
            col=0;
        }else {
            col=1;
        }
        var temp=[sortarr[i],col];
        newarr.push(temp);
    }

    for(var j=0;j<n;j++){
        for(var k=0;k<n;k++) {
            if (arr[j] === newarr[k][0]) {
                result.push(newarr[k][1]);
            }
        }
    }

    print(result);

}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var m = nextInt();
    var arr = [];
    var pos = [];
    var r = [];
    for (var i = 0; i < 101; i++) {
        r[i] = -1;
    }
    for (var i = 0; i < n; i++) {
        arr[i] = nextInt();
        pos[arr[i]] = i;
    }
    for (var i = 0; i < m; i++) {
        var x = nextInt();
        var y = nextInt();
    }
    var s="";
    arr.sort();
    for (var i = 0; i < n; i++) {
        r[pos[arr[i]]] = i % 2;
    }
    for (var i = 0; i < 101; i++) {
        if (r[i] != -1) {
            s += r[i] + " ";
        }
    }
    print(s);
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var m = nextInt();
    var arr = [];
    for (var i = 0; i < n; i++) {
        arr[i] = nextInt();
    }
    for (var i = 0; i < m; i++) {
        var x = nextInt();
        var y = nextInt();
    }
    var s = "";
    var r = [];
    for (var i = 0; i < 101; i++) {
        r[i] = i % 2;
    }
    for (var i = 0; i < n; i++) {
        s += r[arr[i]] + " ";
    }
    print(s);
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

var Point = (function () {
    function Point(x) {
        this.pre = 0;
        this.pos = 0;
        this.color = -1;
        this.pos = x;
        this.pre = x;
    }
    Point.prototype.putSeg = function (left, right) {
        if (left < this.pre) {
            this.pre = left;
        }
        if (right > this.pos) {
            this.pos = right;
        }
    };
    return Point;
})();

function main() {
    var arr = [];
    var arrC = [];
    var n = nextInt();
    var m = nextInt();
    for (var i = 0; i < n; i++) {
        arr[i] = nextInt();
    }
    for (var i = 0; i <= 100; i++) {
        arrC[i] = new Point(i);
    }
    for (var i = 0; i < m; i++) {
        var l = nextInt();
        var r = nextInt();
        for (var j = l; j <= r; j++) {
            arrC[j].putSeg(l, r);
        }
    }
    for (var i = 0; i < n; i++) {
        for (var j = arrC[arr[i]].pre; j <= arrC[arr[i]].pos; j++) {
            arrC[j].color++;
        }
    }
    var s = "";
    for (var i = 0; i < n; i++) {
        s += (arrC[arr[i]].color % 2) + " ";
    }
    print(s);
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var m = nextInt();
    for (var i = 0; i < n; i++) {
        var x = nextInt();
    }
    for (var i = 0; i < m; i++) {
        var x = nextInt();
        var y = nextInt();
    }
    var s = "0";
    for (var i = 1; i < n; i++) {
        s = s + " " + (i % 2);
    }
    print(s);
}

main();


var x = readline()
  .split(" ")
  .map(x => Number(x));
var n = x[0],
  a = x[1],
  b = x[2];
var c = readline()
  .split(" ")
  .map(x => Number(x));

var min = Math.min(a, b);

var price = 0;
var possible = true;

for (var i = 0; i < c.length; i++) {
  var j = c.length - i - 1;

  if (c[i] === 2) {
    if (c[j] === 0) {
      price += a;
    } else if (c[j] === 1) {
      price += b;
    } else {
      price += min;
    }
  } else if (c[i] !== c[j] && c[j] !== 2) {
    possible = false;
  }
}

if (possible) {
  print(price);
} else {
  print(-1);
}

var input=readline().split(' ').map(Number);
var arr=readline().split(' ').map(Number);
var long=(input[0]-1),white=input[1],black=input[2],result=0,check=true;
for(var i=0;i<=long/2;i++){
    if(arr[i]!=arr[long-i]&&arr[i]!=2&&arr[long-i]!=2){
        check=false;
        break;
    }else
        if(arr[i]+arr[long-i]===4){
            if(i!=(long-i))
                result+=black>white?2*white:2*black;
            else
                result+=black>white?white:black;
        }else if(arr[i]===2){
            result+=arr[long-i]===0?white:black;
        }else if(arr[long-i]===2)
            result+=arr[i]===0?white:black;
}
print(check?result:"-1");

var par = readline().split(" ").map( (x) => parseInt(x));
var n = par[0];
var price = [par[1], par[2]]
var minPrice = par[1]<par[2]?par[1]:par[2];
var arr = readline().split(" ").map( (x) => parseInt(x));
var result = 0;
var fail = false;
for(var i = 0; i<parseInt(n/2); i++) {
    if(arr[i]!==2&&arr[n-1-i]!==2) {
        if(arr[i]!==arr[n-1-i]) {
            fail = true;
            break;
        } else {
            continue;
        }
    }
    if(arr[i]===2&&arr[n-1-i]===2) {
        result+=2*minPrice;
        continue;
    }
    if(arr[i]===2) {
        result += price[arr[n-1-i]]
    }
    else {
        result += price[arr[i]]
    }
}
if(fail) {
    result = -1;
} else if(n%2===1&&arr[parseInt(n/2)]===2) {
    result += minPrice;
}
print(result);

var Readcount = readline().split(' ').map(Number);
  var ArrayReadcount = new Array(3)
      ArrayReadcount[0] = Readcount[0];  ArrayReadcount[1] = Readcount[1];  ArrayReadcount[2] = Readcount[2];
           var cheapest = 0;
           var calc = 0;

if(ArrayReadcount[1] < ArrayReadcount[2] ){
    cheapest = ArrayReadcount[1]
} else{
  cheapest = ArrayReadcount[2]
}

    //  var j = document.getElementById('i').value;
      var Values = readline().split(' ');

 var limit = 0;
//alert(parseInt(Values.length/2) + " " + (Values.length/2))
if ( parseInt(Values.length/2) != (Values.length/2) ){

limit = Math.floor(Values.length/2);
}else{
limit = parseInt(Values.length/2);
}

      for (var x = 0; x < limit; x++)
       {

var y = x + 1;

if (Values[x] + Values[Values.length - y] == "01" ){
 calc = -1;
 break; }

else if ( Values[x] + Values[Values.length - y] == "10"){
 calc = -1;
 break; }

//alert( x + " " + Values[x] + Values[Values.length - y]  );

if(Values[x] + Values[Values.length - y] == "22"){calc = calc + (cheapest * 2)}

if(Values[x] + Values[Values.length - y] == "21"){calc = calc + ArrayReadcount[2]}
if(Values[x] + Values[Values.length - y] == "12" ){calc = calc + ArrayReadcount[2]}

if(Values[x] + Values[Values.length - y] == "20") {calc = calc + ArrayReadcount[1]}
if(Values[x] + Values[Values.length - y] == "02" ) {calc = calc + ArrayReadcount[1]}

      }

        if (calc != "-1") {

        if (limit != (Values.length / 2)){
        if (Values[limit] == "2") {calc = calc + cheapest}
        }
        }

        print(calc);

/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./sources/hackerrank/algorithms/practice/strings/highest-value-palindrome-copy/index.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./helpers/input-manager.js":
/*!**********************************!*\
  !*** ./helpers/input-manager.js ***!
  \**********************************/
/*! exports provided: InputManager */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputManager", function() { return InputManager; });
const fs = __webpack_require__(/*! fs */ "fs");

class InputManager {
    static getInput() {
        return new Promise((resolve) => {
            let input = '';

            if (fs.existsSync('./input.txt')) {
                input = fs.readFileSync('./input.txt').toString();
                resolve(this.parseInputString(input));
            } else {
                process.stdin.resume();
                process.stdin.setEncoding('utf-8');
                process.stdin.on('data', inputStdin => {
                    input += inputStdin;
                });

                process.stdin.on('end', () => {
                    resolve(this.parseInputString(input));
                });
            }
        });
    }

    static parseInputString(input) {
        return input.replace(/\s*$/, '')
            .split('\n')
            .map(str => str.replace(/\s*$/, ''));
    }
}

/***/ }),

/***/ "./helpers/solution-manager.js":
/*!*************************************!*\
  !*** ./helpers/solution-manager.js ***!
  \*************************************/
/*! exports provided: SolutionManager */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolutionManager", function() { return SolutionManager; });
class SolutionManager {
    static printSolution(solutionFn) {
        let result = solutionFn();
        if (typeof result !== 'undefined') {
            if (Array.isArray(result)) {
                result.forEach(v => console.log(v));
            } else {
                console.log(result);
            }
        }
    }
}

/***/ }),

/***/ "./sources/hackerrank/algorithms/practice/strings/highest-value-palindrome-copy/index.js":
/*!***********************************************************************************************!*\
  !*** ./sources/hackerrank/algorithms/practice/strings/highest-value-palindrome-copy/index.js ***!
  \***********************************************************************************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _helpers_solution_manager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../../../helpers/solution-manager */ "./helpers/solution-manager.js");
/* harmony import */ var _helpers_input_manager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../../../helpers/input-manager */ "./helpers/input-manager.js");

_helpers_input_manager__WEBPACK_IMPORTED_MODULE_1__["InputManager"].getInput().then((input) => _helpers_solution_manager__WEBPACK_IMPORTED_MODULE_0__["SolutionManager"].printSolution(() => {
    let [n, a, b] = input.shift().split(' ').map(v => Number(v));
    let suits = input.shift().split(' ').map(v => Number(v));
    let costs = [a, b];
    let totalCost = 0;
    let i = 0;

    for (i = 0; i < Math.floor(n / 2); i++) {
        let mirrorIndex = n - 1 - i;

        if (suits[i] !== suits[mirrorIndex]) {
            if (suits[mirrorIndex] !== 2 && suits[i] !== 2) {
                return -1;
            }

            let colorIndex = suits[mirrorIndex] === 2 ? mirrorIndex : i;
            totalCost += costs[mirrorIndex === colorIndex ? suits[i] : suits[mirrorIndex]];
        } else if (suits[mirrorIndex] === 2 && suits[i] === 2) {
            totalCost += Math.min(a, b) * 2;
        }
    }

    if (suits[i] === 2 && n % 2 !== 0) {
        totalCost += Math.min(a, b);
    }

    return totalCost;
}));

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("fs");

/***/ })

/******/ });
//# sourceMappingURL=index.built.js.map

var ip = readline().split(' ').map(Number);
var n = ip[0],line = readline().split(' ').map(Number),sum = 0,ar = new Array(3),match = true;
ar[0] = ip[1];ar[1] = ip[2];ar[2] = 101;
for (var i =0;i<=(n-1)/2;i++){
    if (line[i] !== line[n-1-i]){
        if (line[i] === 2 || line[n-i-1] === 2){
            sum += Math.min(ar[line[i]],ar[line[n-1-i]]);
        } else {
            sum = -1;
            break;
        }
    } else if (line[i] === 2 && line[n-1-i] === 2){
            sum += Math.min(ar[0],ar[1]) * (i === n-1-i ? 1:2);
    }
}
print(sum)

const x = readline()
  .split(" ")
  .map(x => Number(x));
const n = x[0],
  a = x[1],
  b = x[2];
const c = readline()
  .split(" ")
  .map(x => Number(x));

const min = Math.min(a, b);

var price = 0;
var possible = true;

for (var i = 0; i < c.length / 2 - 1; i++) {
  const j = c.length - i - 1;
  if (c[i] === 2 && c[j] === 2) {
    price += min * 2;
  } else if (c[i] === 2) {
    price += add(c[j]);
  } else if (c[j] === 2) {
    price += add(c[i]);
  } else if (c[i] !== c[j]) {
    possible = false;
  }
}

if (c.length % 2 === 1 && c[Math.floor(c.length / 2)] === 2) {
  price += min;
}

if (possible) {
  print(price);
} else {
  print(-1);
}

function add(color) {
  if (color === 0) {
    return a;
  } else {
    return b;
  }
}

var input=readline().split(' ').map(Number);
var arr=readline().split(' ').map(Number);
var long=(input[0]-1),white=input[1],black=input[2],result=0,check=true;
for(var i=0;i<=(long+1)/2;i++){
    if(arr[i]!=arr[long-i]&&arr[i]!=2&&arr[long-i]!=2){
        check=false;
        break;
    }else
        if(arr[i]+arr[long-i]===4){
            if(i!=(long-i))
                result+=black>white?2*white:2*black;
            else
                result+=black>white?white:black;
        }else if(arr[i]===2){
            result+=arr[long-i]===0?white:black;
        }else if(arr[long-i]===2)
            result+=arr[i]===0?white:black;
}
print(check?result:"-1");

var par = readline().split(" ").map( (x) => parseInt(x));
var n = par[0];
var price = [par[1], par[2]]
var minPrice = par[1]<par[2]?par[1]:par[2];
var arr = readline().split(" ").map( (x) => parseInt(x));
var result = 0;
for(var i = 0; i<parseInt(n/2); i++) {
    if(arr[i]!==2&&arr[n-1-i]!==2) continue;
    if(arr[i]===2&&arr[n-1-i]===2) {
        result+=2*minPrice;
        continue;
    }
    if(arr[i]===2) {
        result += price[arr[n-1-i]]
    }
    else {
        result += price[arr[i]]
    }
}
if(n%2===1&&arr[parseInt(n/2)]===2) {
    result += minPrice;
}
print(result);


n=readline()
if (n%2)
{
    print("black")
}
else
{
    print("white")
    print("1 2")
}

var n = parseInt(readline());
if (n % 2 == 0)
	print("white\n1 2");
else
	print("black");