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)); } /* (Z/p^a[1] * ... * Z/p^a[k]) / (p^b[1], ..., p^b[k]) 0 <= b[i] <= a[i] [ p^a[1] ] [ ... ] [ p^a[k] ] [ p^b[1] ... p^b[k] ] a >= c [ p^c ] = [ 0 1 ] [ p^a ] [ 0 ] = [ -1 p^(a-c) ] [ p^c ] a <= c [ p^a ] = [ 1 0 ] [ p^a ] [ 0 ] = [ -p^(c-a) 1 ] [ p^c ] */ void experiment() { void check(int[] as) { const n = cast(int)(as.length); auto prods = new int[n + 1]; prods[0] = 1; foreach (i; 0 .. n) { prods[i + 1] = prods[i] * (as[i] + 1); } foreach (p; 0 .. prods[n]) { const bs = iota(n).map!(i => p / prods[i] % (as[i] + 1)).array; auto aas = new int[n]; auto cs = bs.dup; // incr b[i] ==> can ignore non-diag entries for isom auto ord = iota(n).array.sort!((i, j) => (bs[i] < bs[j])); foreach (i; ord) { if (as[i] >= cs[i]) { aas[i] = cs[i]; cs[] += (as[i] - cs[i]); } else { aas[i] = as[i]; } } writeln(as, " ", bs, ": ", aas); } } void dfs(int[] as) { check(as); if (as.length < 4) { foreach (a; (as.empty ? 1 : as[$ - 1]) .. 4) { dfs(as ~ a); } } } dfs([]); } enum LIM = 10^^5 + 10; int[] lpf; int[string] cache; int calc(int[][] ass) { const key = ass.to!string; auto ptr = (key in cache); if (ptr) return *ptr; bool[int] app; auto bss = new int[][ass.length]; foreach (i; 0 .. ass.length) { bss[i] = new int[ass[i].length]; } void check() { if (ass != bss) { auto bssRed = bss.map!(bs => bs.filter!"a > 0".array).filter!"!a.empty".array; bssRed.sort; const res = calc(bssRed); app[res] = true; } } void dfs(int i, int j) { if (i == ass.length) { check(); } else if (j == ass[i].length) { dfs(i + 1, 0); } else { foreach (b; (j ? ass[i][j - 1] : 0) .. ass[i][j] + 1) { bss[i][j] = b; dfs(i, j + 1); } } } dfs(0, 0); int ret; for (ret = 0; ret in app; ++ret) {} debug { writeln(ass, ": ", ret); stdout.flush; } return cache[key] = ret; } // (Z/aZ)^* int solve(int a) { int[][int] ess; for (; a > 1; ) { const p = lpf[a]; int e; do { ++e; a /= p; } while (a % p == 0); if (p == 2) { if (e == 1) { // Z/1 } else if (e == 2) { // Z/2 ess[2] ~= 1; } else { // Z/2 * Z/2^(e-2) ess[2] ~= 1; ess[2] ~= e - 2; } } else { // Z/(p^(e-1) (p-1)) if (e >= 2) { ess[p] ~= e - 1; } for (int b = p - 1; b > 1; ) { const q = lpf[b]; int f; do { ++f; b /= q; } while (b % q == 0); ess[q] ~= f; } } } debug { writeln("ess = ", ess); } int[][] ass; foreach (p, es; ess) { es.sort; ass ~= es; } ass.sort; return calc(ass); } void main() { lpf = iota(LIM).array; foreach (p; 2 .. LIM) if (lpf[p] == p) { for (int n = 2 * p; n < LIM; n += p) chmin(lpf[n], p); } // experiment; /* foreach (a; 1 .. 10^^5 + 1) { const res = solve(a); // writeln(a, " ", solve(a)); // stdout.flush; } writeln("|cache| = ", cache.length); stdout.flush; //*/ try { for (; ; ) { const N = readInt; auto A = new int[N]; foreach (i; 0 .. N) { A[i] = readInt; } int ans; foreach (i; 0 .. N) { ans ^= solve(A[i]); } writeln(ans ? "Y" : "X"); } } catch (EOFException e) { } }