import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint, q = rint;
	long[] ps = rlong(n);

	Finite[] prods = [Finite(1)];
	foreach(p; ps) prods ~= (prods[$ - 1] * p) / 100;
	log("prods:", prods);

	Finite[] invprods = [Finite(1)];
	foreach(p; ps) invprods ~= (invprods[$ - 1] * 100) / p;
	log("invprods:", invprods);

	Finite[] sums = [Finite(0)];
	foreach(pr; prods) sums ~= sums[$ - 1] + pr;
	log("sums:", sums);

	auto seg1 = new SegTree!int(0, n, (x, y) => y, 0);
	seg1.setValue(0, n, 0);
	log("seg1:\n", seg1);

	auto seg2 = new SegTree!int(0, n, (x, y) => y, 0);
	seg2.setValue(0, n, n);
	log("seg2:\n", seg2);

	Finite ans = (sums[n] - sums[0]) * invprods[n];
	log("ans:", ans);
	foreach(_; 0 .. q){
		int u = rint - 1;
		int i = seg1.getValue(u), j = seg2.getValue(u);
		if(i < u){ // u is not a checkpoint
			seg2.setValue(i, u, u), seg1.setValue(u, j, u);
			log("u:", u, "i:", i, "j:", j);
			log("seg1:\n", seg1);
			log("seg2:\n", seg2);
			ans -= (sums[j] - sums[i]) * invprods[j];
			ans += (sums[u] - sums[i]) * invprods[u];
			ans += (sums[j] - sums[u]) * invprods[j];
		}
		else{ // u is a checkpoint
			i = seg1.getValue(u - 1);
			seg2.setValue(i, u, j), seg1.setValue(u, j, i);
			log("u:", u, "i:", i, "j:", j);
			log("seg1:\n", seg1);
			log("seg2:\n", seg2);
			ans -= (sums[u] - sums[i]) * invprods[u];
			ans -= (sums[j] - sums[u]) * invprods[j];
			ans += (sums[j] - sums[i]) * invprods[j];
		}
		ans.writeln;
	}
}

const long mod = 998244353;
struct Finite{
	long value;
	private static long[] _inv = [0, 1], _frac = [1, 1], _invfrac = [1, 1];
	this(long v){ value = val(v); }
	static long val(long v){
		if(v >= 0) return v % mod;
		else return (v + mod  - (v / mod) * mod) % mod;
	}
	bool opCast(T: bool)(){ return value != 0; }
	Finite opUnary(string s){ long v;
		if(s == "+") v = value;
		else if(s == "-") v = mod - value;
		else if(s == "++") v = value + 1;
		else if(s == "--") v = value + mod - 1;
		else assert(0, "Operator unary " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opBinary(string s)(Finite b){
		return opBinary!s(b.value);
	}
	Finite opBinary(string s)(long u){ long v;
		if(s == "+") v = value + u;
		else if(s == "-") v = value + mod - u;
		else if(s == "*") v = value * u;
		else if(s == "/") v = value * inv(u);
		else assert(0, "Operator " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opBinaryRight(string s)(long u){ long v;
		if(s == "+") v = u + value;
		else if(s == "-") v = u + mod - value;
		else if(s == "*") v = u * value;
		else if(s == "/") v = u * invvalue;
		else assert(0, "Operator " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opAssign(long v){ value = v; return this; }
	Finite opOpAssign(string s)(Finite b){
		return opOpAssign!s(b.value);
	}
	Finite opOpAssign(string s)(long v){
		if(s == "+") value = (value + v) % mod;
		else if(s == "-") value = (value + mod - v) % mod;
		else if(s == "*") value = (value * v) % mod;
		else if(s == "/") value = (value * inv(v)) % mod;
		else assert(0, "Operator " ~ s ~ "= not implemented");
		return this;
	}
	bool opEquals(Finite b){
		return(value == b.value);
	}
	string toString(){ return value.to!string; }
	long inv(long v){
		v = val(v);
		while(v >= _inv.length){
			_inv ~= _inv[mod % $] * (mod - mod / _inv.length) % mod;
		}
		return _inv[v.to!int];
	}
	long invvalue(){
		return inv(value);
	}
	static Finite opCall(long v){ return Finite(val(v)); }

}

class SegTree(T){
	T delegate(T, T) apply;
	T initial;
	int a, b; // a <= x < b を担当する
	bool hasValue;
	SegTree left, right; // 左の子(a <= x < c)、右の子(c <= x < b)
	T value;
	this(int a, int b, T delegate(T, T) apply, T initial = T.init){
		this.a = a, this.b = b;
		this.apply = apply;
		this.initial = initial;
		this.value = initial;
		if(b - a == 1){
			this.hasValue = 1;
		}
		else{
			int c = (a + b) / 2;
			this.left = new SegTree(a, c, apply, initial);
			this.right = new SegTree(c, b, apply, initial);
		}
	}

	// [a, b) に値を設定する ※[a, b) はこのノードの担当区間とかぶっていなくてもよい
	void setValue(int a, int b, T value){
		if(b <= this.a || this.b <= a) return;
		if(a <= this.a && this.b <= b){
			this.hasValue = true;
			this.value = apply(this.value, value);
		}
		else{
			if(this.hasValue){
				left.setValue(left.a, left.b, this.value);
				right.setValue(right.a, right.b, this.value);
				this.hasValue = false;
			}
			left.setValue(a, b, value);
			right.setValue(a, b, value);
		}
	}

	// iにおける値 ※iは必ずこのノードの担当区間内である前提
	T getValue(int i){
		assert(a <= i && i < b);
		if(this.hasValue) return this.value;
		else if(i < left.b) return left.getValue(i);
		else return right.getValue(i);
	}

	// 配列に変換したもの（デバッグ用）
	T[] array(){
		T[] res;
		foreach(i; a .. b) res ~= this.value;
		return res;
	}

	// 文字列に変換したもの（デバッグ用）
	override string toString(){
		if(this.hasValue) return this.array.to!string;
		else return left.toString ~ right.toString;
	}
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

struct ModInt(int M_) {
  alias M = M_;
  int x;
  this(ModInt a) { x = a.x; }
  this(long a) { x = cast(int)(a % M); if (x < 0) x += M; }
  ref ModInt opAssign(long a) { return (this = ModInt(a)); }
  ref ModInt opOpAssign(string op)(ModInt a) {
    static if (op == "+") { x += a.x; if (x >= M) x -= M; }
    else static if (op == "-") { x -= a.x; if (x < 0) x += M; }
    else static if (op == "*") { x = cast(int)((cast(long)(x) * a.x) % M); }
    else static if (op == "/") { this *= a.inv(); }
    else static assert(false);
    return this;
  }
  ref ModInt opOpAssign(string op)(long a) {
    static if (op == "^^") {
      ModInt t2 = this, te = ModInt(1);
      for (long e = a; e; e >>= 1) {
        if (e & 1) te *= t2;
        t2 *= t2;
      }
      x = cast(int)(te.x);
      return this;
    } else return mixin("this " ~ op ~ "= ModInt(a)");
  }
  ModInt inv() const {
    int a = x, b = M, y = 1, z = 0, t;
    for (; ; ) {
      t = a / b; a -= t * b;
      if (a == 0) {
        assert(b == 1 || b == -1);
        return ModInt(b * z);
      }
      y -= t * z;
      t = b / a; b -= t * a;
      if (b == 0) {
        assert(a == 1 || a == -1);
        return ModInt(a * y);
      }
      z -= t * y;
    }
  }
  ModInt opUnary(string op)() const if (op == "-") { return ModInt(-x); }
  ModInt opBinary(string op, T)(T a) const { return mixin("ModInt(this) " ~ op ~ "= a"); }
  ModInt opBinaryRight(string op)(long a) const { return mixin("ModInt(a) " ~ op ~ "= this"); }
  string toString() const { return x.to!string; }
}

enum MO = 998244353;
alias Mint = ModInt!MO;

// 1 + p0 + p0 p1 + p0 p1 p2
struct Info {
  Mint prod, sum;
  Info opBinary(string op)(Info a) const if (op == "*") {
    return Info(prod * a.prod, sum + prod * a.sum);
  }
}
enum IDENTITY = Info(Mint(1), Mint(0));

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      const Q = readInt();
      auto P = new int[N];
      foreach (i; 0 .. N) {
        P[i] = readInt();
      }
      auto U = new int[Q];
      foreach (q; 0 .. Q) {
        U[q] = readInt() - 1;
      }

      int segN;
      for (segN = 1; segN < N; segN <<= 1) {}
      auto seg = new Info[segN << 1];
      seg[] = IDENTITY;
      foreach (i; 0 .. N) {
        seg[segN + i] = Info(Mint(P[i]) / 100, Mint(1));
      }
      foreach_reverse (a; 1 .. segN) {
        seg[a] = seg[a << 1] * seg[a << 1 | 1];
      }
      Info rangeProd(int a, int b) {
        Info retL = IDENTITY, retR = IDENTITY;
        for (a += segN, b += segN; a < b; a >>= 1, b >>= 1) {
          if (a & 1) retL = retL * seg[a++];
          if (b & 1) retR = seg[--b] * retR;
        }
        return retL * retR;
      }
      Mint calc(int a, int b) {
        const res = rangeProd(a, b);
        const ret = res.sum / res.prod;
        debug {
          writeln("calc ", a, " ", b, ": ", res, " ", ret);
        }
        return ret;
      }

      auto set = new RedBlackTree!int;
      set.insert(0);
      set.insert(N);
      Mint now = calc(0, N);
      foreach (q; 0 .. Q) {
        const l = set.lowerBound(U[q]).back;
        const r = set.upperBound(U[q]).front;
        if (set.removeKey(U[q])) {
          debug {
            writeln("remove ", U[q], "; ", l, " ", r);
          }
          now -= calc(l, U[q]);
          now -= calc(U[q], r);
          now += calc(l, r);
        } else {
          debug {
            writeln("insert ", U[q], "; ", l, " ", r);
          }
          set.insert(U[q]);
          now -= calc(l, r);
          now += calc(l, U[q]);
          now += calc(U[q], r);
        }
        writeln(now);
      }
    }
  } catch (EOFException e) {
  }
}


import std.stdio;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import core.stdc.stdio : scanf;
import std.conv;
import std.array;
import std.string;
import std.range;
import std.algorithm;

T read(T)() { return readln.chomp.to!T; }
T[] readarray(T)() { return readln.chomp.split(" ").map!(to!T).array; }

void solve() {
    int n, q;
    readf!" %d %d "(n, q);
    auto a = readarray!long;
    long odds, evens;
    long oddn, evenn;
    foreach(el; a) {
        if (el & 1) {
            odds += el;
            oddn++;
        }
        else {
            evens += el;
            evenn++;
        }
    }
    foreach(casenum; 0 .. q) {
        byte type;
        long x;
        readf!" %d %d "(type, x);
        if (type == 0) {
            evens += evenn*x;
            writeln(odds + evens);
            if (x & 1) {
                oddn += evenn;
                odds += evens;
                evenn = 0;
                evens = 0;
            }
        }
        else {
            odds += oddn*x;
            writeln(odds + evens);
            if (x & 1) {
                evenn += oddn;
                evens += odds;
                oddn = 0;
                odds = 0;
            }
        }
    }
}

void main() {
    int T = read!int;
    foreach (t; 0 .. T) solve();
}

import std.algorithm, std.array, std.container, std.conv, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void main()
{
  foreach (casenum ; 1 .. readln.strip.to!int + 1) {
    long n, q;
    readf!" %d %d "(n, q);
    auto a = readln.splitter.map!(to!long).array;
    long cntodd, cnteven, ans;
    foreach (x ; a) {
      if (x % 2 == 0)
        cnteven++;
      else
        cntodd++;
      ans += x;
    }
    foreach (i ; 0 .. q) {
      long type, xj;
      readf!" %d %d "(type, xj);
      if (type == 0) {
        ans += cnteven * xj;
        if (xj % 2 != 0) {
          cntodd += cnteven;
          cnteven = 0;
        }
      } else {
        ans += cntodd * xj;
        if (xj % 2 != 0) {
          cnteven += cntodd;
          cntodd = 0;
        }
      }
      writeln(ans);
    }
  }
}


// B
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

struct ModInt(int M_) {
  import std.conv : to;
  alias M = M_;
  int x;
  this(ModInt a) { x = a.x; }
  this(long a) { x = cast(int)(a % M); if (x < 0) x += M; }
  ref ModInt opAssign(long a) { return (this = ModInt(a)); }
  ref ModInt opOpAssign(string op)(ModInt a) {
    static if (op == "+") { x += a.x; if (x >= M) x -= M; }
    else static if (op == "-") { x -= a.x; if (x < 0) x += M; }
    else static if (op == "*") { x = cast(int)((cast(long)(x) * a.x) % M); }
    else static if (op == "/") { this *= a.inv(); }
    else static assert(false);
    return this;
  }
  ref ModInt opOpAssign(string op)(long a) {
    static if (op == "^^") {
      if (a < 0) return (this = inv()^^(-a));
      ModInt t2 = this, te = ModInt(1);
      for (long e = a; e > 0; e >>= 1) {
        if (e & 1) te *= t2;
        t2 *= t2;
      }
      x = cast(int)(te.x);
      return this;
    } else return mixin("this " ~ op ~ "= ModInt(a)");
  }
  ModInt inv() const {
    int a = x, b = M, y = 1, z = 0, t;
    for (; ; ) {
      t = a / b; a -= t * b;
      if (a == 0) {
        assert(b == 1 || b == -1);
        return ModInt(b * z);
      }
      y -= t * z;
      t = b / a; b -= t * a;
      if (b == 0) {
        assert(a == 1 || a == -1);
        return ModInt(a * y);
      }
      z -= t * y;
    }
  }
  ModInt opUnary(string op: "-")() const { return ModInt(-x); }
  ModInt opBinary(string op, T)(T a) const {
    return mixin("ModInt(this) " ~ op ~ "= a");
  }
  ModInt opBinaryRight(string op)(long a) const {
    return mixin("ModInt(a) " ~ op ~ "= this");
  }
  bool opCast(T: bool)() const { return (x != 0); }
  string toString() const { return x.to!string; }
}

enum MO = 998244353;
alias Mint = ModInt!MO;

enum LIM = 10^^6 + 10;
Mint[] inv, fac, invFac;
void prepare() {
  inv = new Mint[LIM];
  fac = new Mint[LIM];
  invFac = new Mint[LIM];
  inv[1] = 1;
  foreach (i; 2 .. LIM) {
    inv[i] = -(Mint.M / i) * inv[cast(size_t)(Mint.M % i)];
  }
  fac[0] = invFac[0] = 1;
  foreach (i; 1 .. LIM) {
    fac[i] = fac[i - 1] * i;
    invFac[i] = invFac[i - 1] * inv[i];
  }
}
Mint binom(long n, long k) {
  if (0 <= k && k <= n) {
    assert(n < LIM);
    return fac[cast(size_t)(n)] * invFac[cast(size_t)(k)] * invFac[cast(size_t)(n - k)];
  } else {
    return Mint(0);
  }
}

void main() {
  prepare;

  try {
    for (; ; ) {
      const N = readInt();
      auto A = new long[2 * N];
      foreach (i; 0 .. 2 * N) {
        A[i] = readLong();
      }
      A.sort;

      Mint ans;
      ans -= A[0 .. N].sum;
      ans += A[N .. 2 * N].sum;
      ans *= binom(2 * N, N);
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

immutable int mod = 998_244_353;

int powMod (int a, int p)
{
	int res = 1 % mod;
	for ( ; p > 0; p >>= 1)
	{
		if (p & 1)
		{
			res = (res * 1L * a) % mod;
		}
		a = (a * 1L * a) % mod;
	}
	return res;
}

void main ()
{
	int n;
	while (readf !(" %s") (n) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		sort (a);

		int f = 1;
		foreach (i; 1..n + 1)
		{
			f = (f * 1L * i) % mod;
		}

		int invF = powMod (f, mod - 2);

		int g = f;
		foreach (i; n + 1..n * 2 + 1)
		{
			g = (g * 1L * i) % mod;
		}

		int add = g;
		add = (add * 1L * invF) % mod;
		add = (add * 1L * invF) % mod;

		int res = 0;
		foreach (i; 1..n * 2)
		{
			int mult = n - abs (n - i);
			int cur = (add * 1L * (a[i] - a[i - 1])) % mod;
			res = (res + cur * 1L * mult) % mod;
		}
		writeln (res);
	}
}

// Cheese-Cracker: cheese-cracker.github.io

const ll PRIME = 998244353;

ll modinv(ll num){
    ll res = 1;
    ll x = num;
    ll y = PRIME-2;
    while(y > 0){
        if(y & 1){
            res *= x;
            res %= PRIME;
        }
        x = x * x;
        x %= PRIME;
        y >>= 1;
    }
    return res;
}

void play(){
    int n;
    n = rd!int;
    ll[] arr = rdarr;
    arr.sort;

    ll s1 = 0, s2 = 0;
    // 1st half
    foreach(i; 0..n){ s1 += arr[i]; }
    // 2nd half
    foreach(i; n..2*n){ s2 += arr[i]; }

    ll res = s2 - s1;
    show(res);
    res %= PRIME;

    ll combi = 1;
    // Multiply 2nCn
    foreach(k; n+1..2*n+1){
        combi *= k;
        combi %= PRIME;
    }
    ll divi = 1;
    foreach(k; 1..n+1){
        divi *= k;
        divi %= PRIME;
    }
    combi *= modinv(divi);
    combi %= PRIME;
    res *= combi;
    res %= PRIME;
    writeln(res);
}

int main(){
    long t = 1;
    /* t = rd;        // Toggle! */
    while(t--) play();  // Let's play!
    stdout.flush;
    return 0;
}

/**********It's A Me Mario!**********/
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;
static string[] inp;
T rd(T = long)(){while(!inp.length) inp = readln.chomp.split; string a = inp[0]; inp.popFront; return a.to!T;}
T[] rdarr(T = long)(){ auto r = readln.chomp.split.to!(T[]); return r; }
void show(A...)(A a) { debug{ foreach(t; a){ write(t, "| "); } writeln; } }
alias ll = long;
alias rbt = redBlackTree;
alias tup = Tuple!(long, "x",  long, "y");
T max(T = long)(T a, T b){ return (a > b) ? a : b; }
T min(T = long)(T a, T b){ return (a < b) ? a : b; }


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		auto p = a.length - a.findAdjacent !(q{a >= b}).length;
		auto q = a.length - a.retro.findAdjacent !(q{a >= b}).length;
		auto lo = a.take (min (p + 1, n)).array;
		auto hi = a.retro.take (min (q + 1, n)).array;
		debug {writeln (lo, " ", hi);}

		string res;
		while (true)
		{
			if (lo.empty)
			{
				res ~= 'R'.repeat (hi.length).text;
				break;
			}

			if (hi.empty)
			{
				res ~= 'L'.repeat (lo.length).text;
				break;
			}

			if (lo.front < hi.front)
			{
				res ~= 'L';
				lo.popFront ();
			}
			else if (lo.front > hi.front)
			{
				res ~= 'R';
				hi.popFront ();
			}
			else if (lo.length < hi.length)
			{
				res ~= 'R'.repeat (hi.length).text;
				break;
			}
			else
			{
				res ~= 'L'.repeat (lo.length).text;
				break;
			}
		}

		res.length = min (res.length, n);
		writeln (res.length);
		writeln (res);
	}
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T read(T)(){ return read.to!T; }
T[] read(T)(long n){ return n.iota.map!(_ => read!T).array; }
T[][] read(T)(long m, long n){ return m.iota.map!(_ => read!T(n)).array; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){

	int n = read.to!int;
	long[] as;
	foreach(i; 0 .. n) as ~= read.to!long;

	string ans;
	int i = 0, j = n - 1;
	long x = -1;
	while(i <= j){
		if(as[i] < as[j]){
			if(x < as[i]) x = as[i], ans ~= "L", i += 1;
			else if(x < as[j]) x = as[j], ans ~= "R", j -= 1;
			else break;
		}
		else{
			if(x < as[j]) x = as[j], ans ~= "R", j -= 1;
			else if(x < as[i]) x = as[i], ans ~= "L", i += 1;
			else break;
		}
	}

	ans.length.writeln;
	ans.writeln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto a = RDR.ARR;

	string ans;
	long last;
	while (!a.empty)
	{
		if (a.front > last && a.front < a.back)
		{
			last = a.front;
			a.popFront;
			ans ~= "L";
		}
		else if (a.back > last && a.back < a.front)
		{
			last = a.back;
			a.popBack;
			ans ~= "R";
		}
		else if (a.front > last)
		{
			last = a.front;
			a.popFront;
			ans ~= "L";
		}
		else if (a.back > last)
		{
			last = a.back;
			a.popBack;
			ans ~= "R";
		}
		else
		{
			break;
		}
	}

	writeln(ans.length);
	writeln(ans);
	stdout.flush();
	debug readln();
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto a = readln.chomp.split.map!(to!int).array;

    void gole(int p, int lm, int lst, ref dchar[] ans) {
        while (p <= lm && a[p] > lst) {
            ans ~= 'L';
            lst = a[p];
            ++p;
        }

        debug { writeln(ans.length); }
    }
    void gor(int p, int lm, int lst, ref dchar[] ans) {
        while (p >= lm && a[p] > lst) {
            ans ~= 'R';
            lst = a[p];
            --p;
        }

        debug { writeln(ans.length); }
    }
    int lst = 0;
    int le = 0, r = n-1;
    dchar[] ans;
    while (le <= r) {
        int leok = lst < a[le];
        int rok = lst < a[r];
        if (!leok && !rok) {
            break;
        }
        if (!leok) {
            gor(r, le, lst, ans);
            break;
        }
        if (!rok) {
            gole(le, r, lst, ans);
            break;
        }

        if (a[le] < a[r]) {
            ans ~= 'L';
            lst = a[le];
            ++le;
        } else if (a[r] < a[le]) {
            ans ~= 'R';
            lst = a[r];
            --r;
        } else {
            dchar[] ansle;
            dchar[] ansr;
            gole(le, r, lst, ansle);
            gor(r, le, lst, ansr);

            if (ansle.length > ansr.length) { ans ~= ansle; }
            else { ans ~= ansr; }
            break;
        }
    }

    ans.length.writeln;
    ans.writeln;
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;
		a.sort();

		bool hasPlus;
		foreach (i; 0..n)
		{
			if (a[i] >= 0)
				hasPlus = true;
		}

		if (!hasPlus || n == 5)
		{
			ans[ti] = 1;
			foreach (i; 0..5)
			{
				ans[ti] *= a[n-i-1];
			}
		}
		else
		{
			long best = long.min;
			foreach (i; 0..3)
			{
				auto cnt = i * 2;
				long x = 1;
				foreach (j; 0..cnt)
				{
					if (a[j] >= 0)
					{
						x = long.min;
						break;
					}

					x *= a[j];
				}
				if (x == long.min) continue;

				foreach (j; 0..5-cnt)
				{
					if (a[n-j-1] < 0)
					{
						x = long.min;
						break;
					}

					x *= a[n-j-1];
				}
				best.chmax(x);
			}
			ans[ti] = best;
		}
	}

	foreach (e; ans)
	{
		writeln(e);
	}
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){
}
void jury(){
}
void solve(){
    foreach(_; 0 .. scan!int){
        int n = scan!int;
        long[] as = scan!long(n);

        long[] xs, ys, zs; // +, -, 0
        foreach(a; as) if(a > 0) xs ~= a; else if(a < 0) ys ~= a; else zs ~= a;

        xs.sort();
        ys.sort();

        long ans = as[0] * as[1] * as[2] * as[3] * as[4];

        if(xs.length >= 5) ans.raiseTo(xs[$ - 1] * xs[$ - 2] * xs[$ - 3] * xs[$ - 4] * xs[$ - 5]);
        if(xs.length >= 4 && ys.length >= 1) ans.raiseTo(xs[0] * xs[1] * xs[2] * xs[3] * ys[$ - 1]);
        if(xs.length >= 3 && ys.length >= 2) ans.raiseTo(xs[$ - 1] * xs[$ - 2] * xs[$ - 3] * ys[0] * ys[1]);
        if(xs.length >= 2 && ys.length >= 3) ans.raiseTo(xs[0] * xs[1] * ys[$ - 1] * ys[$ - 2] * ys[$ - 3]);
        if(xs.length >= 1 && ys.length >= 4) ans.raiseTo(xs[$ - 1] * ys[0] * ys[1] * ys[2] * ys[3]);
        if(ys.length >= 5) ans.raiseTo(ys[$ - 1] * ys[$ - 2] * ys[$ - 3] * ys[$ - 4] * ys[$ - 5]);

        if(zs.length >= 1) ans.raiseTo(0);

        ans.writeln;

    }
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;
		a.sort();

		bool hasPlus;
		foreach (i; 0..n)
		{
			if (a[i] >= 0)
				hasPlus = true;
		}

		if (!hasPlus)
		{
			ans[ti] = 1;
			foreach_reverse (i; 0..5)
			{
				ans[ti] *= a[i];
			}
		}
		else
		{
			long best = long.min;
			foreach (i; 0..3)
			{
				auto cnt = i * 2;
				long x = 1;
				foreach (j; 0..cnt)
				{
					if (a[j] >= 0)
					{
						x = long.min;
						break;
					}

					x *= a[j];
				}
				if (x == long.min) continue;

				foreach (j; 0..5-cnt)
				{
					if (a[n-j-1] < 0)
					{
						x = long.min;
						break;
					}

					x *= a[n-j-1];
				}
				best.chmax(x);
			}
			ans[ti] = best;
		}
	}

	foreach (e; ans)
	{
		writeln(e);
	}
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;
		a.sort();

		bool hasPlus;
		foreach (i; 0..n)
		{
			if (a[i] >= 0)
				hasPlus = true;
		}

		if (!hasPlus || n == 5)
		{
			ans[ti] = 1;
			foreach_reverse (i; 0..5)
			{
				ans[ti] *= a[i];
			}
		}
		else
		{
			long best = long.min;
			foreach (i; 0..3)
			{
				auto cnt = i * 2;
				long x = 1;
				foreach (j; 0..cnt)
				{
					if (a[j] >= 0)
					{
						x = long.min;
						break;
					}

					x *= a[j];
				}
				if (x == long.min) continue;

				foreach (j; 0..5-cnt)
				{
					if (a[n-j-1] < 0)
					{
						x = long.min;
						break;
					}

					x *= a[n-j-1];
				}
				best.chmax(x);
			}
			ans[ti] = best;
		}
	}

	foreach (e; ans)
	{
		writeln(e);
	}
	stdout.flush;
	debug readln;
}


import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;
import std.range;
import std.numeric;
import std.traits;

void main(string[] args)
{
  auto n = next!int;
  auto y = next!int(n);
  int[] can(int max)
  {
    auto used = redBlackTree!int();
    auto res = new int[](n);
    foreach(i, yi; y)
      {
	while(yi > max)
	  yi >>= 1;
	while(yi && yi in used)
	  yi >>= 1;
	if (yi == 0) return null;
	used.insert(yi);
	res[i] = yi;
      }
    return res;
  }
  int low = 1;
  int high = y.fold!max;
  int[] lowestCan = null;
  while(low <= high)
    {
      int mid = (low + high) / 2;
      if (auto res = can(mid))
	{
	  lowestCan = res;
	  high = mid - 1;
	}
      else
	{
	  low = mid + 1;
	}
    }
  foreach(yi; lowestCan)
    write(yi, " ");
  writeln;
}

static this()
{
  popChar;
}

struct Any(T)
{
  static auto read()
  {
    static if (is(T == char))
      {
	auto res = frontChar;
	popChar;
	return res;
      }
  }
}

struct Unsigned(T)
{
  auto read()
  {
    auto res = T(0);
    while(!frontChar.isDigit) popChar;
    do
      {
	res = res * T(10) + T(frontChar - '0');
	popChar;
      }
    while(frontChar.isDigit);
    return res;
  }
}

struct Matrix(T, alias rows, alias cols)
{
  T[][] _cell;
  alias _cell this;
  // Ring constructor
  this(int n)
  {
    final switch(n)
      {
      case 0:
	_cell = new T[][](rows, cols);
	break;
      case 1:
	debug assert(rows == cols);
	_cell = new T[][](rows, cols);
	foreach(i; 0 .. rows)
	  _cell[i][i] = T(1);
	break;
      }
  }
  // Copy constructor
  this(Matrix!(T, rows, cols) other)
  {
    _cell = new T[][](rows, cols);
    foreach(i; 0 .. rows)
      _cell[i][] = other[i][];
  }
  auto opBinary(string op)(Matrix!(T, rows, cols) other)
       if (op == "+" || op == "-")
	 {
	   auto res = Matrix!(T, rows, cols)(0);
	   foreach(i; 0 .. rows)
	     foreach(j; 0 .. cols)
	       res[i][j] = mixin(q{this[i][j]}, op, q{other[i][j]});
	   return res;
	 }
  auto opBinary(string op, alias otherRows, alias otherCols)(Matrix!(T, otherRows, otherCols) other)
       if (op == "*")
	 {
	   debug assert(cols == otherRows);
	   auto res = Matrix!(T, rows, otherCols)(0);
	   foreach(i; 0 .. rows)
	     foreach(k; 0 .. cols)
	       foreach(j; 0 .. otherCols)
		 res[i][j] += this[i][k] * other[k][j];
	   return res;
	 }
  ref auto opOpAssign(string op)(Matrix!(T, rows, cols) other)
  {
    static if (op == "*")
      {
	debug assert(rows == cols);
	alias n = rows;
	auto res = Matrix!(T, n, n)(0);
	T factor;
	foreach(i; 0 .. n)
	  foreach(k; 0 .. n)
	    foreach(j; 0 .. n)
	      res[i][j] += this[i][k] * other[k][j];
	foreach(i; 0 .. n)
	  this[i][] = res[i][];
      }
    else
      {
	foreach(i; 0 .. rows)
	  foreach(j; 0 .. cols)
	    mixin(q{this[i][j] }, text(op, q{=}), q{ other[i][j];});
      }
    return this;
  }
  mixin powMethod;
}

struct Mod(T, alias mod)
{
  alias This = Mod!(T, mod);
  T _rep;
  this(T t)
  {
    _rep = t % mod;
    if (_rep < 0) _rep += mod;
  }
  static auto plain(T t)
  {
    auto res = Mod!(T, mod)();
    res._rep = t;
    return res;
  }
  static auto fromPositive(T t)
  {
    pragma(inline, true);
    return Mod!(T, mod).plain(t % mod);
  }
  static auto fromNegative(T t)
  {
    pragma(inline, true);
    return Mod!(T, mod).plain(t % mod + mod);
  }
  string toString()
  {
    return to!string(_rep);
  }
  debug invariant
  {
    assert(_rep >= 0 && _rep < mod);
  }
  auto opBinary(string op)(This b)
  {
    static if (op == "+")
      {
	T resrep = _rep + b._rep;
	if (resrep >= mod) resrep -= mod;
	return This.plain(resrep);
      }
    else static if (op == "-")
      {
	T resrep = _rep - b._rep;
	if (resrep < 0) resrep += mod;
	return This.plain(resrep);
      }
    else static if (op == "*")
      {
	return This.fromPositive(_rep * b._rep);
      }
  }
  auto opOpAssign(string op)(This b)
  {
    mixin(q{_rep }, text(op, "="), q{b._rep;});
    static if (op == "+")
      {
	if (_rep >= mod) _rep -= mod;
      }
    else static if (op == "-")
      {
	if (_rep < 0) _rep += mod;
      }
    else static if (op == "*")
      {
	_rep %= mod;
      }
    return this;
  }

  auto opBinary(string op)(long exp)
       if (op == "^^")
	 {
	   return pow(exp);
	 }
  mixin powMethod;
}

mixin template powMethod()
{
  auto pow(this ThisType)(long exp)
    {
      auto res = ThisType(1);
      auto pow = ThisType(this);
      while(exp)
	{
	  if (exp & 1) res *= pow;
	  pow *= pow;
	  exp >>= 1;
	}
      return res;
    }
}
// INPUT
char frontChar;
void popChar()
{
  import core.stdc.stdio;
  frontChar = cast(char) getchar;
  if (feof(stdin)) frontChar = ' ';
}
auto makeArray(T, S...)(S s)
{
  enum brackets = () {
    string res;
    foreach(i; 0 .. s.length)
      res ~= "[]";
    return res;
  } ();
  mixin(q{alias Type = T}, brackets, q{;});
  return new Type(s);
}
template isNumberLike(T)
{
  enum isNumberLike = is(typeof((){T test; test = test + test * test; test *= test;}()));
}
void popWhite()
{
  import std.ascii;
  while (frontChar.isWhite) popChar;
}
void print(T...)(T t)
{
  static foreach(ti; t)
    {
      static if (is(typeof(ti) == string))
	{
	  write(ti, " ");
	}
      else static if (isArray!(typeof(ti)))
	{
	  foreach(e; ti) print(e);
	}
      else static if (isTuple!(typeof(ti)))
	{
	  static foreach(i; ti.length) writesp(ti[i]);
	}
      else
	{
	  write(ti, " ");
	}
    }
}
void println(T...)(T t)
{
  static if (t.length == 0)
    writeln;
  static foreach(ti; t)
    {
      print(ti);
      writeln;
    }
}
auto next(alias T, S...)(S s)
{
  pragma(inline, true);
  static if (s.length > 0)
    {
      auto res = makeArray!(typeof(next!T()))(s);
      S t;
      enum loops = () {
	string res;
	foreach(i; 0 .. s.length)
	  {
	    auto ti = text(q{t[}, i, q{]});
	    res ~= text(q{for(}, ti, q{ = 0;}, ti , q{ < s[}, i, q{];}, ti, q{++)});
	  }
	return res;
      } ();
      enum indexing = () {
	string res = "res";
	foreach(i; 0 .. s.length)
	  res ~= text(q{[t[}, i, q{]]});
	return res;
      } ();
      mixin(loops, indexing, q{ = next!T;});
      return res;
    }
  else
    {
      static if (isNumberLike!T)
	{
	  import std.ascii: isDigit;
	  T res;
	  while(frontChar.isWhite) popChar;
	  T multiplier = T(1);
	  if (frontChar == '-')
	    {
	      multiplier = T(-1);
	      popChar;
	    }
	  else if (frontChar == '+')
	    {
	      popChar;
	    }
	  debug assert(frontChar.isDigit);
	  do
	    {
	      res = res * T(10) + T(frontChar - '0');
	      popChar;
	    }
	  while(frontChar.isDigit);
	  return multiplier * res;
	}
      else static if (is(T == string))
	{
	  import std.ascii: isWhite;
	  string res;
	  while(frontChar.isWhite)
	    popChar;
	  while(!frontChar.isWhite)
	    {
	      res ~= frontChar;
	      popChar;
	    }
	  return res;
	}
      else static if (is(T == char))
	{
	  while(frontChar.isWhite) popChar;
	  auto res = frontChar;
	  popChar;
	  return res;
	}
      else
	{
	  return T.read;
	}
    }
}

import std.bigint,std.container,std.array,std.algorithm,std.conv,std.functional,std.math,std.numeric,std.string,std.range,std.complex,std.typecons,std.regex,
std.random,std.uni,std.traits,std.variant;
import core.stdc.stdio : freopen;
import core.stdc.stdlib : system;
import std.stdio;
//import core.stdc.stdio;
alias RedBlackTree Rbt;
alias redBlackTree rbt;
alias BigInt big;
alias pair!(int,int) pii;
alias pair!(long,long) pll;
alias BoyerMooreFinder strfind;
immutable int mod=1000000007;
pure nothrow T lcm (T)(auto ref T a,auto ref T b)
{
	return a/gcd(a,b)*b;
}
pure nothrow X binpow(X,Y)(X base,Y exp)
if(is(typeof(exp&1)))
{
	if(exp<0)return X(0);
	X res=X(1);
	while(exp>0)
	{
		if(exp&1)res*=base;
		base*=base;
		exp>>=1;
	}
	return res;
}
pure nothrow auto binpow(X,Y,Z)(X base,Y exp,in Z mm)
if(is(typeof(exp&1)))
{
	if(mm==0) return binpow(base,exp);
	if(exp<0)return X(0);
	auto res=X(1)%mm;
	while(exp>0)
	{
		if(exp&1)res=(res*base)%mm;
		base*=base;
		base%=mm;
		exp>>=1;
	}
	return res;
}
void putarr(X)(in X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
void putarr(X)(X a,in int n,in int m)
{
	foreach(i;0..n)
	{
		foreach(j;0..m)write(a[i][j],' ');
		writeln;
	}
}
bool getarr(X)(X a,in int n){bool b=1; foreach(ref i;a[0..n])b=input(&i);return b;}
bool input(T...)(T ptrs) if (ptrs.length > 0) {return readf(replicate(" %s", ptrs.length), ptrs)==ptrs.length;}
struct pair(X,Y)
{
	X first;
	Y second;
	alias first fi;
	alias second se;
	this(X a_,Y b_){
		fi=a_;
		se=b_;
	}
	this(this){fi=fi;se=se;}
	this(A,B)(auto ref pair!(A,B) p) if(is(A:X) && is(B:Y))
	{
		fi=p.fi;
		se=p.se;
	}
	int opCmp(A,B)(in pair!(A,B) s_) const pure nothrow @safe if(is(typeof(s_.fi<fi)==bool) && is(typeof(s_.se<se)==bool))
	{
		int cmp=0-(fi<s_.fi)+(fi>s_.fi);
		if(cmp!=0)return cmp;
		else return (0-(se<s_.se)+(se>s_.se));
	}
};
pair!(X,Y) mp(X,Y)(in X x_,in Y y_) pure nothrow @safe
{
	pair!(X,Y) pp;
	pp.fi=x_;
	pp.se=y_;
	return pp;
}
X sqr(X)(in X a_) pure nothrow @property @safe @nogc {return a_*a_;}
X cub(X)(in X a_) pure nothrow @property @safe @nogc {return a_*a_*a_;}
nothrow @nogc @system void inf(in char* name) {freopen(name,"r",core.stdc.stdio.stdin);}
nothrow @nogc @system void ouf(in char* name) {freopen(name,"w",core.stdc.stdio.stdout);}
@property auto arread(T)(){return readln.split.map!(to!(T)).array;}
nothrow pure size_t lowb(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	size_t l=0,r=a.length;
	while(r-l>1)
	{
		auto m=(l+r)>>1;
		if(!(a[m]<g))r=m;
		else l=m;
	}
	return (!(a[l]<g))?l:r;
}
pure nothrow size_t upb(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	size_t l=0,r=a.length;
	while(r-l>1)
	{
		auto m=(l+r)>>1;
		if(g<a[m])r=m;
		else l=m;
	}
	return (g<a[l])?l:r;
}
pure nothrow size_t binf(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	size_t l=0,r=a.length;
	while(r-l>1)
	{
		auto m=(l+r)>>1;
		if(!(a[m]<g))r=m;
		else l=m;
	}
	return (g==a[l])?l:a.length;
}
pure nothrow bool binary_search(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
{
	return binf(a,g)!=a.length;
}
pure nothrow V foldr(R,V,T)(R range,T arg,V nach) if(isFunction!T && isInputRange!R && is(typeof(arg(nach,R.front))==V))
{
	for(;!range.empty;range.popFront()) nach=arg(nach,range.front);
	return nach;
}
pure nothrow size_t countr(R,T)(R range,T fun) if(isFunction!T && isInputRange!R && is(typeof(fun(R.front))==bool))
{
	size_t nach;
	for(;!range.empty;range.popFront()) nach+=fun(range.front);
	return nach;
}
pure nothrow T orient_square(T)(pair!(T,T)[] figure...) if(figure.length>2 && is(typeof(figure.front*figure.front)==T))
{
	auto n=figure.front,t=figure.front;
	figure.popFront();
	T ans=0;
	for(;!figure.empty;figure.popFront())
	{
		ans+=(figure.front.fi-t.fi)*(figure.front.se+t.se);
		t=figure.front;
	}
	return ans+(n.fi-t.fi)*(n.se+t.se);
}
pure nothrow real square(T)(pair!(T,T)[] figure...) if(figure.length>2 && is(typeof(figure.front*figure.front)==T))
{
	return abs(orient_square(figure))/2.00000000000;
}
//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin cumulativeFold schwartzSort multiSort partialSort heapify join filter
//---------------------------------------------------------------program beginning-----------------------------------------------------------------

void main()
{
	int n;
	while(input(&n))
	{
		auto q=rbt!(true,int);
		foreach(i;0..n)
		{
			int k;
			input(&k);
			q.insert(k);
		}
		for(;;)
		{
			int t=q.back;
			int d;
			for(int i=2;i<=t;i*=2)
			{
				if(q.equalRange(t/i).empty){
					d=t/i;
					break;
				}
			}
			if(d==0)break;
			q.removeKey(t);
			q.insert(d);
		}
		putarr(q);
		writeln;
	}
	debug system("pause");
}

import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(int)).array;
		auto r = redBlackTree !(q{a > b}, int) ();
		foreach (c; a)
		{
			r.insert (c);
		}
		while (true)
		{
			auto v = r.front ();
			auto w = v;
			while (w > 1)
			{
				w /= 2;
				if (w !in r)
				{
					break;
				}
			}
			if (w !in r)
			{
				r.removeKey (v);
				r.insert (w);
			}
			else
			{
				break;
			}
		}
		writefln ("%(%s %)", r[]);
	}
}


import std.algorithm, std.array, std.container, std.conv, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void main()
{
  foreach (casenum ; 1 .. readln.strip.to!int + 1) {
    auto n = readln.strip.to!long;
    auto a = readln.splitter.map!(to!long).array.sort.array;
    long totalsum = a.sum;
    long xsum = 0;
    long ans = 0;
    foreach (x ; a) {
      xsum += x;
      ans = max(ans, abs(abs(xsum) - abs(totalsum - xsum)));
    }
    writeln(ans);
  }
}

import std.stdio;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import core.stdc.stdio : scanf;
import std.conv;
import std.array;
import std.string;
import std.range;
import std.algorithm;
import std.functional;

T read(T)() { return readln.chomp.to!T; }
T[] readarray(T)() { return readln.chomp.split(" ").map!(to!T).array; }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

void solve() {
    int n = read!int;
    auto a = readarray!long;
    long plus, minus;
    foreach(e; a)
        if (e > 0)
            plus += e;
        else
            minus += e;
    writeln(abs(plus - abs(minus)));
}

void main() {
    int T = read!int;
    foreach (t; 0 .. T) solve();
}


module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string[] tk;
        string readString() {
                while (tk.empty)
                        tk = readln.split;
                auto tkt = tk.front;
                tk.popFront;
                return tkt;
        }
        int readInt() {
                return readString.to!int;
        }
        double readDouble() {
                return readString.to!double;
        }
}

void main() {
        IO cin;
        int t = 1;
        // t = cin.readInt;
        while (t--) {
                int na = cin.readInt;
                int nb = cin.readInt;
                int a = cin.readInt;
                int b = cin.readInt;
                int[] arr1 = new int[na];
                int[] arr2 = new int[nb];
                foreach (ref i; arr1) i = cin.readInt;
                foreach (ref i; arr2) i = cin.readInt;
                bool possible = true;
                for (int i = 0; i < a; i++) if (arr1[i] >= arr2[nb - b]) possible = false;
                writeln(possible ? "YES" : "NO");
        }
}

module main;
import std.c.stdio;

int main() {
  int na, nb;
  scanf("%d %d", &na, &nb);
  int k, m;
  scanf("%d %d", &k, &m);
  int a[100005];
  int b[100005];
  for (int i = 0; i < na; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < nb; i++) {
    scanf("%d", &b[i]);
  }
  if (a[k - 1] < b[nb - m]) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}

import std.stdio, std.range, std.string, std.conv, std.algorithm;
import std.math;

void main() {
    readln;
    int k, m;
    readf("%d %d\n", &k, &m);
    int[] a = readln.chomp.split.map!(to!int).array;
    int[] b = readln.chomp.split.map!(to!int).array;

    if (a[k - 1] < b[$ - m]) {
        "YES".writeln;
    } else {
        "NO".writeln;
    }
}

import std.stdio, std.range, std.string, std.conv, std.algorithm;
import std.math;

void main() {
    readln;
    int k, m;
    readf("%d %d\n", &k, &m);
    int[] a = readln.chomp.split.map!(to!int).array;
    int[] b = readln.chomp.split.map!(to!int).array;

    if (a[k - 1] < b[0]) {
        "YES".writeln;
    } else {
        "NO".writeln;
    }
}


import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main ()
{
	auto d = readln.strip.to !(int).iota.array;
	auto a = readln.split.map !(to !(int)).array;
	a[] += d[];
	sort (a);
	a[] -= d[];
	writeln (isSorted (a) ? a.map !(text).join (" ") : ":(");
}

import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;
void main ()
{
	auto d = readln.strip.to !(int).iota.array;
	auto a = readln.split.map !(to !(int)).array;
	a[] += d[];
	sort (a);
	a[] -= d[];
	if (!isSorted (a))
	{
		writeln (":(");
	}
	else
	{
		writefln ("%(%s %)", a);
	}
}

import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

void main ()
{
	int n;
	while (readf (" %s ", &n) > 0)
	{
		auto a = readln.split.map !(to !(int)).array;
		a[] -= n.iota.retro.array[];
		if (!equal (a, a.uniq))
		{
			writeln (":(");
		}
		else
		{
			sort !(q{a < b}, SwapStrategy.stable) (a);
			a[] += n.iota.retro.array[];
			if (a.canFind !(q{a < 0}))
			{
				writeln (":(");
			}
			else if (!isSorted !(q{a < b}) (a))
			{
				writeln (":(");
			}
			else
			{
				writefln ("%(%s %)", a);
			}
		}
	}
}

import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;
void main ()
{
	readln;
	auto a = readln.split.map !(to !(uint)).array;
	a[] -= a.length.iota.retro.array[];
	sort (a);
	a[] += a.length.iota.retro.array[];
	if (!isSorted (a))
	{
		writeln (":(");
	}
	else
	{
		writefln ("%(%s %)", a);
	}
}

import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

void main ()
{
	int n;
	while (readf (" %s ", &n) > 0)
	{
		auto a = readln.split.map !(to !(int)).array;
		a[] -= n.iota.retro.array[];
		if (!equal (a, a.uniq))
		{
			writeln (":(");
		}
		else
		{
			sort !(q{a < b}, SwapStrategy.stable) (a);
			a[] += n.iota.retro.array[];
			writefln ("%(%s %)", a);
		}
	}
}

import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;
void main ()
{
	readln;
	auto a = readln.split.map !(to !(uint)).array;
	a[] -= a.length.iota.retro.array[];
	sort (a);
	a[] += a.length.iota.retro.array[];
	if (!equal (a, a.uniq) || !isSorted (a))
	{
		writeln (":(");
	}
	else
	{
		writefln ("%(%s %)", a);
	}
}


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

enum INF = 10L^^18;

void main() {
  try {
    for (; ; ) {
      const numCases = readInt;
      foreach (caseId; 0 .. numCases) {
        const N = readInt;
        const X = readLong;
        auto A = new long[N];
        foreach (i; 0 .. N) {
          A[i] = readLong;
        }

        int ans;
        long lb = -INF, ub = INF;
        foreach (i; 0 .. N) {
          const llb = max(lb, A[i] - X);
          const uub = min(ub, A[i] + X);
          if (llb <= uub) {
            lb = llb;
            ub = uub;
          } else {
            ++ans;
            lb = A[i] - X;
            ub = A[i] + X;
          }
        }
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		int n, x;
		readf !(" %s %s") (n, x);
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		int lo = a.front;
		int hi = a.front;
		int res = 0;
		foreach (ref c; a)
		{
			lo = min (lo, c);
			hi = max (hi, c);
			if (hi - lo > x * 2)
			{
				res += 1;
				lo = c;
				hi = c;
			}
		}
		writeln (res);
	}
}


// Cheese-Cracker: cheese-cracker.github.io
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.bigint, std.numeric, std.math, std.random;

alias ll = long;
alias to!int isz;
alias rbt = redBlackTree;
static string[] token;
T rd(T = long)() { while(!token.length) token = readln.chomp.split; string res = token[0]; token.popFront; return res.to!T; }
T[] rdarr(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
/*******************************It's a Me, Mario!**********************************************/

void play(){
    int n;
    n = rd!int;
    ll[] arr = rdarr;
    ll[] res;
    ll cnt0 = 0, cnt1 = 0;
    foreach(el; arr){
        cnt0 += (el == 0);
        cnt1 += (el == 1);
    }
    ll hf = n / 2;
    ll put = hf + (hf % 2);
    if(cnt1 > hf || (hf % 2 == 0 && cnt1 == hf)){
        writeln(put);
        foreach(i; 0..put){
            write(1, " ");
        }
    }else if(cnt0 >= hf){
        writeln(cnt0);
        foreach(i; 0..cnt0){
            write(0, " ");
        }
    }
    writeln;
}

int main(){
    ll t = 1;
    t = rd;        // Toggle!
    while(t--) play();  // Let's play!
    stdout.flush;
    return 0;
}

import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;
import std.range;
import std.numeric;

void main(string[] args)
{
  inputFile = stdin;
  auto t = next!int;
  foreach(tc; 0 .. t)
    {
      auto n = next!int;
      auto a = next!int(n);
      int[2] cnt;
      foreach(ai; a) cnt[ai]++;
      if (cnt[0] >= cnt[1])
	{
	  writeln(cnt[0]);
	  foreach(i; 0 .. cnt[0]) write("0 ");
	  writeln;
	}
      else
	{
	  cnt[1] -= cnt[1] % 2;
	  writeln(cnt[1]);
	  foreach(i; 0 .. cnt[1]) write("1 ");
	  writeln;
	}
    }
}
ulong bitCnt(long x)
{
  ulong cnt = 0;
  while(x) {cnt += x & 1; x>>=1;}
  return cnt;
}
alias Arr(T) = Mat!(T, 1);
struct Mat(T, size_t dimension)
{
  T[] _baseArray;
  T[] _slice;
  size_t[dimension] _sizes; size_t dim(size_t i) {return _sizes[i];}
  size_t[dimension] _indexer;
  this(T[] baseArray, size_t[dimension] sizes)
  {
    _baseArray = baseArray;
    _sizes = sizes;
    _indexer[dimension - 1] = 1;
    static foreach_reverse(i; 0 .. dimension - 1)
      _indexer[i] = _indexer[i + 1] * _sizes[i + 1];
    auto requiredSize = _indexer[0] * _sizes[0];
    debug assert(_baseArray.length >= requiredSize);
    _slice = _baseArray[0 .. requiredSize];
  }
  this(size_t[dimension] sizes)
  {
    size_t reqSize = 1;
    static foreach(i; 0 .. dimension)
      reqSize *= sizes[i];
    this(new T[](reqSize), sizes);
  }
  ref auto opIndex()
  {
    pragma(inline, true);
    return _slice[];
  }
  ref auto opIndex(I...)(I i)
  {
    pragma(inline, true);
    debug assert(i.length <= dimension);
    size_t index = mixin(iota(0, i.length).map!(j => text("i[", j, "]*_indexer[", j, "]")).join("+"));
    static if (i.length == dimension)
      {
	return _slice[index];
      }
    else
      {
	enum sliceDimension = dimension - i.length;
	size_t[sliceDimension] remSizes = _sizes[i.length .. $];
	auto basePortion = _slice[index .. index + _indexer[i.length - 1]];
 	return Mat!(T, sliceDimension)(basePortion, remSizes);
      }
  }
  static if (dimension == 2)
    {
      auto identity()
      {
	debug assert(dim(0) == dim(1));
	auto n = dim(0);
	auto id = Mat!(T, 2)([n, n]);
	foreach(k; 0 .. n)
	  id[k, k] = T(1);
	return id;
      }
      bool canMultiply(Mat!(T, 2) b)
      {
	return this.dim(1) == b.dim(0);
      }
      auto opBinary(string op)(Mat!(T, 2) b)
	if (op == "*")
	  {
	    debug assert(canMultiply(b));
	    auto res = Mat!(T, 2)([this.dim(0), b.dim(1)]);
	    foreach(i; 0 .. res.dim(0))
	      foreach(k; 0 .. this.dim(1))
		foreach(j; 0 .. res.dim(1))
		  res[i, j] = res[i, j] + this[i, k] * b[k, j];
	    return res;
	  }
      auto opBinary(string op)(ulong exp)
	if (op == "^^")
	  {
	    return this.pow(identity, exp);
	  }
      mixin interiorBinPow;
    }
}

struct Mod(T, ulong mod)
{
  alias This = Mod!(T, mod);
  T _rep; T rep() {return _rep;}
  this(W)(W w)
  {
    _rep = ((cast(T) w)%mod + mod) % mod;
  }
  static auto plainConstruct(T t)
  {
    pragma(inline, true);
    debug assert(t >= 0 && t < mod);
    auto res = Mod!(T, mod).init;
    res._rep = t;
    return res;
  }
  string toString()
  {
    return to!string(rep);
  }
  debug invariant
  {
    assert(_rep >= 0 && _rep < mod);
  }
  auto opBinary(string op)(This b)
  {
    static if (op == "+")
      {
	T resrep = _rep + b._rep;
	if (resrep >= mod) resrep -= mod;
	return This.plainConstruct(resrep);
      }
    else static if (op == "-")
      {
	T resrep = _rep - b._rep;
	if (resrep < 0) resrep += mod;
	return This.plainConstruct(resrep);
      }
    else static if (op == "*")
      {
	return This(_rep * b._rep);
      }
  }
}

mixin template interiorBinPow()
{
  alias ThisType = typeof(this);
  auto pow(ThisType res, ulong exp)
    {
      if (exp < 0) debug assert(0);
      auto pow = this;
      while(exp)
	{
	  if (exp & 1)
	    res = res * pow;
	  pow = pow * pow;
	  exp >>= 1;
	}
      return res;
    }
}

// INPUT
File inputFile;
DList!string _words;
void _wordsFill()
{
  while (_words.empty) _words.insertBack(inputFile.readln.split);
}
string popWord()
{
  _wordsFill;
  auto word = _words.front;
  _words.removeFront;
  return word;
}
string peekWord()
{
  _wordsFill;
  return _words.front;
}
T next(T)()
{
  return to!T(popWord);
}
T peek(T)()
{
  return to!T(peekWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;

		long cnt0, cnt1;
		foreach (i; 0..n)
		{
			if (a[i] == 0)
				++cnt0;
			else
				++cnt1;
		}
		if (cnt0 >= cnt1)
		{
			foreach (i; 0..cnt0)
				ans[ti] ~= 0;
		}
		else
		{
			if ((n/2) % 2)
			{
				foreach (i; 0..n/2+1)
					ans[ti] ~= 1;
			}
			else
			{
				foreach (i; 0..n/2)
					ans[ti] ~= 1;
			}
		}
	}

	foreach (e; ans)
	{
		writeln(e.length);
		e.map!(to!string).join(" ").writeln;
	}
	stdout.flush;
	debug readln;
}

// Cheese-Cracker: cheese-cracker.github.io
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.bigint, std.numeric, std.math, std.random;

alias ll = long;
alias to!int isz;
alias rbt = redBlackTree;
static string[] token;
T rd(T = long)() { while(!token.length) token = readln.chomp.split; string res = token[0]; token.popFront; return res.to!T; }
T[] rdarr(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
/*******************************It's a Me, Mario!**********************************************/

void play(){
    int n;
    n = rd!int;
    ll[] arr = rdarr;
    ll[] res;
    ll cnt0 = 0, cnt1 = 0;
    foreach(el; arr){
        cnt0 += (el == 0);
        cnt1 += (el == 1);
    }
    ll put = (n/2) + (n % 2);
    ll hf = n / 2;
    if(cnt1 > hf || (hf % 2 == 0 && cnt1 == hf)){
        writeln(put);
        foreach(i; 0..put){
            write(1, " ");
        }
    }else if(cnt0 >= hf){
        writeln(cnt0);
        foreach(i; 0..cnt0){
            write(0, " ");
        }
    }
    writeln;
}

int main(){
    ll t = 1;
    t = rd;        // Toggle!
    while(t--) play();  // Let's play!
    stdout.flush;
    return 0;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;

		bool hasZero;
		foreach (i; 0..n)
		{
			if (a[i] == 0)
				hasZero = true;
		}
		if (hasZero)
			ans[ti] = [0];
		else
			ans[ti] = [1, 1];
	}

	foreach (e; ans)
	{
		writeln(e.length);
		e.map!(to!string).join(" ").writeln;
	}
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;

		long cnt0, cnt1;
		foreach (i; 0..n)
		{
			if (a[i] == 0)
				++cnt0;
			else
				++cnt1;
		}
		if (cnt0 >= cnt1)
		{
			foreach (i; 0..n/2)
				ans[ti] ~= 0;
		}
		else
		{
			foreach (i; 0..n/2)
				ans[ti] ~= 1;
		}
	}

	foreach (e; ans)
	{
		writeln(e.length);
		e.map!(to!string).join(" ").writeln;
	}
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;

		long cnt0, cnt1;
		foreach (i; 0..n)
		{
			if (a[i] == 0)
				++cnt0;
			else
				++cnt1;
		}
		if (cnt0 > cnt1)
		{
			foreach (i; 0..(n+2)/2)
				ans[ti] ~= 0;
		}
		else
		{
			if ((n/2) % 2)
			{
				foreach (i; 0..n/2-1)
					ans[ti] ~= 1;
				if (cnt0 == 0)
					ans[ti] ~= [1, 1];
				else
					ans[ti] ~= 0;
			}
			else
			{
				foreach (i; 0..n/2)
					ans[ti] ~= 1;
			}
		}
	}

	foreach (e; ans)
	{
		writeln(e.length);
		e.map!(to!string).join(" ").writeln;
	}
	stdout.flush;
	debug readln;
}