2
1 31
 2
1 0
 10
450661 128600 993228 725823 293549 33490 843121 903634 556169 448234
 1
1
 5
1 3 5 7 9
 6
524 529 5249 524 529 529
 3
1 2 3
 2
0 1
 55
0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 5 6 7 8 9 6 7 8 9 7 8 9 8 9 9
 16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 3
128 1024 2048
 10
3 3 3 5 5 3 3 3 3 5
 1
0
 2
1 2
 2
0 0
 2
1 1

0
 2
 632
 0
 0
 24
 2
 2
 621247139
 64594
 4
 0
 1
 1
 3
 0

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class JzzhuAndNumbers_task4 {
    public static int[] numbers;

    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner();
        BufferedWriter printer = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = scanner.readInt();
        numbers = new int[n];

        for (int i = 0; i < n; i++)
            numbers[i] = scanner.readInt();

        Arrays.sort(numbers);
        int result = 0;
        for (int i = 0; i <= numbers[numbers.length - 1]; i++)
            result += IntegerPower(-1, g(i)) * (1<<f(i));

        printer.write(result);
    }

    public static int f(int x) {
        if(x == 0)
            return numbers.length;
        int result = 0;
        for (int i = 0; i < numbers.length; i++)
            if ((x & numbers[i]) == x)
                result++;
        return result;
    }

    public static int g(int x) {
        int result = 0;
        for (int i = 0; i < 20; i++)
            if ((x & (1 << i)) != 0)
                result++;
        return result;
    }

    public static int IntegerPower(int base, int pow) {
        int result = 1;
        for (int i = 0; i < pow; i++)
            result *= base;
        return result;
    }
}

class MyScanner {
    BufferedReader bufferedReader;
    StringTokenizer stringTokenizer;

    public MyScanner() {
        bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    }

    int readInt() throws IOException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
            stringTokenizer = new StringTokenizer(bufferedReader.readLine());
        }
        return Integer.parseInt(stringTokenizer.nextToken());
    }

}