import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[][] nums = new boolean[n][31]; for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = 0; j < 31; j++) { nums[i][j] = (x % 2 == 1); x /= 2; } } long ans = 0; for (int i = 0; i < 31; i++) { int count = 0; for (int j = 0; j < n; j++) { if (nums[j][i]) { count++; } } if (count >= n - count) { ans += (1L << i) * (n - count); } else { ans += (1L << i) * count; } } System.out.println(ans); } }