#include using namespace std; #define pb push_back #define eb emplace_back //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); #define mod 998244353 #define ll long long #define inf 0x3f3f3f3f #define INF 0x3f3f3f3f3f3f3f3f inline int read() { char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();} int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();} if(nega==-1) return -ans; return ans; } void print(vector x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);} #define N 100005 vector> factor(int x) { vector> ans; for(int i=2;i*i<=x;i++) { if(x%i==0) { int c=0; while(x%i==0) x/=i,c++; ans.eb(i,c); } } if(x!=1) ans.eb(x,1); return ans; } int vis[N]; int mex(const vector &v) { for(int i=0;i<(int)v.size()+3;i++) vis[i]=0; for(int i:v) vis[i]=1; for(int i=0;;i++) if(!vis[i]) return i; } map>,int> sg; int getmex(vector> state) { if(sg.find(state)!=sg.end()) return sg[state]; vector> dif; int prod=1; for(auto v:state) { vector td; for(int j=0;j<(int)v.size();j++) { int w=v[j]-(j==0?0:v[j-1]); td.pb(w+1); prod*=w+1; } // print(v); dif.pb(td); } // cout<<"* "< trans; for(int i=1;i> res; for(int j=0;j<(int)state.size();j++) { vector tmp; for(int k=0;k<(int)state[j].size();k++) { int w=state[j][k]-id%dif[j][k]; if(w) tmp.pb(w); id/=dif[j][k]; } res.pb(tmp); } sort(res.begin(),res.end()); trans.pb(getmex(res)); } return sg[state]=mex(trans); } int solve(int x) { static map vis; if(vis.find(x)!=vis.end()) return vis[x]; map> res; auto add=[&](int p,int c) { if(res.find(p)==res.end()) res[p]={}; res[p].pb(c); }; for(auto [p,c]:factor(x)) { if(p==2) { if(c>=2) add(2,1); if(c>=3) add(2,c-2); } else { if(c>=2) add(p,c-1); for(auto [w,t]:factor(p-1)) add(w,t); } } vector> state; for(auto [p,v]:res) { vector tmp=v; sort(v.begin(),v.end()); state.pb(v); } sort(state.begin(),state.end()); return vis[x]=getmex(state); } signed main() { int n=read(),ans=0; for(int i=1;i<=n;i++) ans^=solve(read()); if(ans) cout<<"Y\n"; else cout<<"X\n"; return 0; }