import std; void main () { int N = readln.split[0].to!(int); int[] A; { int[] buf = readln.split.to!(int[]); foreach (_; 0..N) { A = buf; } } solve(N, A); } void solve (int N, int[] A) { const int digits = 28; int[][] cumsum = new int[][](A.length + 1, digits); // bit累積和 foreach (idx, a; A) { foreach (x; 0..digits) { cumsum[idx + 1][x] = cumsum[idx][x]; } for (int i = 0; 0 < a; i++) { cumsum[idx + 1][i] += a % 2; a /= 2; } } long ans = 0; foreach (i; 0..N) { int[] power = new int[](digits); foreach (x; 0..digits - 1) { power[x] = cumsum[N][x] - cumsum[i][x]; } int radix = 2; int base = 1; foreach (how; power) { ans += how * base; base *= radix; } } foreach (x; cumsum) { writeln(x); } writeln(ans); }