#include #define PPque priority_queue, vector>, greater>> #define Pque priority_queue, vector>, greater>> #define pque priority_queue, greater> #define umap unordered_map #define uset unordered_set #define rep(i, s, f) for(ll i = s; i <= f; i++) #define per(i, s, f) for(ll i = s; i >= f; i--) #define all0(x) (x).begin() ,(x).end() #define all(x) (x).begin() + 1, (x).end() #define vvvi vector>> #define vvvl vector>> #define vvvc vector>> #define vvvd vector>> #define vvi vector> #define vvl vector> #define vvs vector> #define vvc vector> #define vvp vector>> #define vvb vector> #define vvd vector> #define vp vector> #define vi vector #define vl vector #define vs vector #define vc vector #define vb vector #define vd vector #define P pair #define TU tuple #define rrr(l, r) mt()%(r-l+1)+l #define ENDL '\n' #define ull unsigned long long #define debug(a, s) rep(i, s, a.size()-1) {cout << a.at(i) << " ";}cout << endl; #define Debug(a, s) rep(i, s, a.size()-1) {rep(j, s, a.at(i).size()-1) {cout << a.at(i).at(j) << " ";}cout << endl;} typedef long long ll; using namespace std; //////////////////////////////////////////////////////////////////////////////////////////////////////////// //これが本当の組み込み関数ってね(笑) template T or_less(vector &A, T x) { //x以下で最大要素の添字 前提: sort済み 存在しない: -1 return distance(A.begin(), upper_bound(A.begin(), A.end(), x)-1); } template T under(vector &A, T x) { //x未満の最大要素の添字 前提: sort済み 存在しない: -1 return distance(A.begin(), lower_bound(A.begin(), A.end(), x)-1); } template T or_more(vector &A, T x) { //x以上で最小要素の添字  前提: sort済み 存在しない: N . //distanceのA.beginは添字を出すために常にA.begin() NG: A.begin() + 1 return distance(A.begin(), lower_bound(A.begin(), A.end(), x)); } template T over(vector &A, T x) { //xより大きい最小要素の添字前提: sort済み 存在しない: N return distance(A.begin(), upper_bound(A.begin(), A.end(), x)); } void compress(vector &A) {//小さい順に順位、大きい順にしたいならreverseはNG最後に変換 vector temp = A; sort(temp.begin()+1, temp.end()); for (int i = 1; i <= int(A.size()-1); i++) { A.at(i) = distance(temp.begin(), lower_bound(temp.begin()+1, temp.end(), A.at(i))); } } ll LIS1(vl &A) {//at(0)は番兵、広義単調増加 ll N = A.size()-1; vl L(N+1, 1001001001001001001LL); L.at(0) = -1 * 1001001001001001001LL; ll ans = 0; rep(i, 1, N) { ll idx = over(L, A.at(i)); L.at(idx) = A.at(i); ans = max(ans, idx); } return ans; } ll LIS2(vl &A) {//狭義単調増加 ll N = A.size() - 1; vl L(N+1, 1001001001001001001LL); L.at(0) = -1 * 1001001001001001001LL; ll ans = 0; rep(i, 1, N) { ll idx = or_more(L, A.at(i)); L.at(idx) = A.at(i); ans = max(ans, idx); } return ans; } ////////////////////////////////////////////////////////////////////// //数学系 /////////////////////////////////////////////////////////////////////// ll POWER(ll a, ll b, ll mod) { a %= mod; vector pow (61); pow.at(0) = a; bitset<60> bina(b); ll answer = 1; for (int i = 1; i <= 60; i++) { pow.at(i) = pow.at(i-1) * pow.at(i-1) % mod; if (bina.test(i-1)) { answer = (answer*pow.at(i-1)) % mod; } } return answer; } ll Div(ll a, ll b, ll mod) { return a * POWER(b, mod-2, mod) % mod; } ll round(ll x, ll i) { return ll(x + 5 * pow(10, i-1))/ll(pow(10, i)) * ll(pow(10, i)); } template //約分 void normalize(T &mol, T &deno) { T mol_temp = abs(mol); T deno_temp = abs(deno); T GCD = gcd(mol_temp, deno_temp); mol /= GCD; deno /= GCD; } vvl mat_mul(vvl &a, vvl &b, ll mod) {//0-indexed && 正方行列 ll n = a.size(); vvl res(n , vl(n, 0)); rep(i, 0, n-1) { rep(j, 0, n-1) { rep(k, 0, n-1) { res.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j); res.at(i).at(j) %= mod; } } } return res; } vvl mat_pow(vvl &a, ll b, ll mod) {//0-indexed && 正方行列 bitset<60> bina(b); vvl power = a; int N = a.size(); vvl res(N, vl(N, 0)); rep(i, 0, N-1) { res.at(i).at(i) = 1; } rep(i, 1, 60) { if (bina.test(i-1)) { res = mat_mul(res, power, mod); } power = mat_mul(power, power, mod); } return res; } vvl comb(ll n, ll mod) {//計算にO(N^2) 読み取りにO(1) vvl v(n+1, vl(n+1, 0)); rep(i, 0, v.size() - 1) { v.at(i).at(0) = 1; v.at(i).at(i) = 1; } rep(i, 1, v.size()-1) { rep(j, 1, i) { v.at(i).at(j) = v.at(i-1).at(j-1) + v.at(i-1).at(j); v.at(i).at(j) %= mod; } } return v; } ll nCk(int n, int k, ll mod) {//毎回O(max(分子、 分母)) ll ue = 1; ll sita = 1; for (int i = 1; i <= k; i++) { sita *= i; sita %= mod; } for (int i = 1; i <= k; i++) { ue *= (n-i+1); ue %= mod; } return Div(ue, sita, mod); } ll gaiseki(P a, P b) { //原点を中心としてaからbの方向 0以下なら角aObが180°以上 return a.first * b.second - a.second * b.first; } ll gaiseki(P a, P b, P c) { //cを中心としてaからbの方向 return (a.first - c.first) * (b.second - c.second) - (a.second - c.second) * (b.first - c.first); } ll nto10(string S, ll base) { ll res = 0; reverse(all0(S)); while(!S.empty()) { ll num = S.back() - '0'; if(num < 0 || num > 9) num = 9 + S.back() - 'a' + 1; res = res * base + num; S.pop_back(); } return res; } string toN(ll N, ll base) { if(N == 0) return "0"; string ans =""; ll MOD = abs(base); while(N != 0) { ll first = N % MOD; while(first < 0) first += MOD; ans += to_string(first); N -= first; N /= base; } reverse(all0(ans)); return ans; } vp factrization(ll N) { vp res; for (int i = 2; i * i <= N; i++) { ll cnt = 0; while(N % i == 0) { cnt++; N /= i; } if(cnt != 0) res.push_back(P(i, cnt)); } if(N != 1) res.push_back(P(N, 1)); return res; } struct comb_fast {//must素数 vl fac; vl facinv; vl inv; ll mod_comb; comb_fast (ll n, ll mod) { mod_comb = mod; fac.assign(n+1, 1); facinv.assign(n+1, 1); inv.assign(n+1, 1); rep(i, 2, n) { fac.at(i) = fac.at(i-1) * i % mod_comb; inv.at(i) = mod_comb - inv.at(mod_comb%i) * (mod_comb/i)%mod_comb; facinv.at(i) = facinv.at(i-1) * inv.at(i) % mod_comb; } } ll get(ll n, ll k) { if(n < k) return 0; if(n < 0 || k < 0) return 0; return fac.at(n) * (facinv.at(k) * facinv.at(n-k)%mod_comb)%mod_comb; } }; double KAKUDO(double rad) { double res = rad * 180 / 3.141592653589793; return res; } double RAD(double kakudo) { return kakudo / 180 * 3.141592653589793; } double KAKUDO(P from, P to, P inside) { from.first -= inside.first; from.second -= inside.second; to.first -= inside.first; to.second -= inside.second; double kakudor = atan2(from.first, from.second); kakudor = KAKUDO(kakudor); double kakudol = atan2(to.first, to.second); kakudol = KAKUDO(kakudol); double res = kakudol - kakudor; if(res < 0)res += 360; if(res > 360) res -= 360; return res; } ll extgcd (ll a, ll b, ll &x, ll &y) { if(b == 0) { x = 1; y = 0; return a; } ll d = extgcd(b, a%b, y, x); y -= a/b * x; return d; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //グローバル変数を置くところ(情報工学意識高め) ll int_max = 1001001001; ll ll_max = 1001001001001001001LL; const double pi = 3.141592653589793; vl dx{0, 1, 0, -1, 0, 1, 1, -1, -1}; vl dy{0, 0, -1, 0, 1, 1, -1, -1, 1}; //#pragma GCC optimize ("-O3") //ll mod = 1000000007; //ll mod = 998244353; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template struct Matrix { int h, w; vector> d; Matrix() {} Matrix(int h, int w, T val = 0): h(h), w(w), d(h, vector(w, val)){} Matrix& unit() { assert(h == w); rep(i, 0, h-1) { d[i][i] = 1; } return *this; } const vector& operator[](int i) const{return d[i];} vector& operator[](int i) {return d[i];} Matrix operator*(const Matrix&a) const{ assert(w == a.h); Matrix r(h, a.w); rep(i, 0, h-1) { rep(k, 0, w-1) { rep(j, 0, a.w-1) { r[i][j] += d[i][k] * a[k][j]; } } } return r; } Matrix pow(ll t) const { assert(h == w); if(!t) return Matrix(h, h).unit(); if(t == 1) return *this; Matrix r = pow(t >> 1); r = r * r; if(t&1) r = r*(*this); return r; } }; void solve() { ll n; cin >> n; ll N = pow(2, n); vl A(N); rep(i, 0, N-1) { cin >> A.at(i); } rep(i, 0, N-1) { rep(j, 0, N-1) { ll idx = i ^ j; if(A[idx] != A[i] ^ A[j]) {cout << "No" << endl; return ;} } } cout << "Yes" << endl; } //stringでの数字の下から1桁目は 正:S.at(N-1) 誤:S.at(0) //if(S.at(i) == 1 ← charなのに1...? // modは取りましたか...?(´・ω・`) int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); solve(); return 0; }