from functools import reduce from itertools import count from operator import xor def factorize(N): ret = [] for p in count(2): if p*p > N: break if N % p == 0: k = 0 while N % p == 0: k += 1 N //= p ret.append((p, k)) if N != 1: ret.append((N, 1)) return ret memo = {} def bktk(A): if len(A) == 0: yield [] return for i in range(A[-1]): for a in bktk(A[:-1]): a.append(i) yield a return def calc(A): # Calculate grundy number of cyclic group, prod(Cp^a) # A should be sorted if A in memo: return memo[A] if len(A) == 0: return 0 grundy = set() # for group C = prod(Cp^ai), backtrack for B / # B = prod(Cp^bi), then a_{i-1} <= b_i <= a_i holds. # this means, 0 <= ai-bi <= a_i-a_{i-1} cA = [1 + A[i] - (0 if i == 0 else A[i-1]) for i in range(len(A))] for dA in bktk(cA): if max(dA) == 0: continue B = tuple(a-da for a, da in zip(A, dA) if a != da) grundy.add(calc(B)) for i in count(0): if i not in grundy: memo[A] = i return i def solve(x): # express G as product of cyclic group # C[p] = [a, b, ...] denotes (Z/xZ)* = Cp^a*Cp^b*... C = {} for p, k in factorize(x): if p not in C: C[p] = [] if p == 2: if k >= 2: C[p].append(1) if k >= 3: C[p].append(k-2) else: if k >= 2: C[p].append(k-1) for q, t in factorize(p-1): if q not in C: C[q] = [] C[q].append(t) # simple transpose algorithm def T(arr): if len(arr) == 0: return () ret = [0] * max(arr) for i in arr: for j in range(i): ret[j] += 1 return tuple(ret) # Here, uses transpose trick. # grundy number of cyclic group quotient can be transposed into game where # arbitary positive number of decks were chosen, and -1 from chosen numbers part = [] for v in C.values(): part.extend(T(v)) part = T(part) return calc(part[::-1]) def main(): int(input()) # N A = map(int, input().split()) G = reduce(xor, map(solve, A)) print(G) print('Y' if G == 0 else 'X') if __name__ == '__main__': main()