Gottfried learned about binary number representation. He then came up with this task and presented it to you.

You are given a collection of n non-negative integers a_1, …, a_n. You are allowed to perform the following operation: choose two distinct indices 1 ≤ i, j ≤ n. If before the operation a_i = x, a_j = y, then after the operation a_i = x~AND~y, a_j = x~OR~y, where AND and OR are bitwise AND and OR respectively (refer to the Notes section for formal description). The operation may be performed any number of times (possibly zero).

After all operations are done, compute ∑_{i=1}^n a_i^2 — the sum of squares of all a_i. What is the largest sum of squares you can achieve?

Input

The first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).

The second line contains n integers a_1, …, a_n (0 ≤ a_i < 2^{20}).

Output

Print a single integer — the largest possible sum of squares that can be achieved after several (possibly zero) operations.

Examples

Input


1
123


Output


15129


Input


3
1 3 5


Output


51


Input


2
349525 699050


Output


1099509530625

Note

In the first sample no operation can be made, thus the answer is 123^2.

In the second sample we can obtain the collection 1, 1, 7, and 1^2 + 1^2 + 7^2 = 51.

If x and y are represented in binary with equal number of bits (possibly with leading zeros), then each bit of x~AND~y is set to 1 if and only if both corresponding bits of x and y are set to 1. Similarly, each bit of x~OR~y is set to 1 if and only if at least one of the corresponding bits of x and y are set to 1. For example, x = 3 and y = 5 are represented as 011_2 and 101_2 (highest bit first). Then, x~AND~y = 001_2 = 1, and x~OR~y = 111_2 = 7.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

public class _globalRound8 {

	static Reader r = new Reader();
	static PrintWriter out = new PrintWriter(System.out);

	private static void solve1() throws IOException {

		int t = r.nextInt();
		StringBuilder res = new StringBuilder();

		while (t-- > 0) {

			int a = r.nextInt();
			int b = r.nextInt();
			int n = r.nextInt();

			int cnt = 0;
			while (a <= n && b <= n) {
				if (a < b) {
					cnt++;
					a += b;
				} else {
					b += a;
					cnt++;
				}
			}

			res.append(cnt).append("\n");
		}

		out.print(res);
		out.close();
	}

	private static void solve2() throws IOException {

		long k = r.nextLong();

		char str[] = "codeforces".toCharArray();

		// representing k as a sum of values of arr
		long arr[] = new long[10];
		Arrays.fill(arr, 1);

		long num_till_now = 1;
		for (int i = 0; num_till_now < k; i = (i + 1) % 10) {
			num_till_now /= arr[i]++;
			num_till_now *= arr[i];
		}

		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < 10; i++) {
			for (int j = 1; j <= arr[i]; j++) {
				ans.append(str[i]);
			}
		}

		out.print(ans);
		out.close();

	}

	static class Pair {
		int fi, se;

		public Pair(int one, int two) {
			fi = one;
			se = two;
		}
	}

	private static void solve3() throws IOException {

		StringBuilder res = new StringBuilder();

		int n = r.nextInt();

		ArrayList<Pair> vertices = new ArrayList<>();
		vertices.add(new Pair(0, 0));
		vertices.add(new Pair(0, 1));
		vertices.add(new Pair(1, 0));
		vertices.add(new Pair(1, 1));

		while (n-- > 0) {
			int x = vertices.get(vertices.size() - 1).fi;
			int y = vertices.get(vertices.size() - 1).se;
			vertices.add(new Pair(x + 1, y));
			vertices.add(new Pair(x, y + 1));
			vertices.add(new Pair(x + 1, y + 1));
		}

		res.append(vertices.size()).append("\n");
		for (Pair vert : vertices) {
			int x = vert.fi, y = vert.se;
			res.append(x + " " + y).append("\n");
		}

		out.print(res);
		out.close();

	}

	private static boolean isOn(int num, int bit) {
		if ((num & (1 << bit)) == 0) {
			return false;
		}
		return true;
	}

	private static void solve4() throws IOException {

		int n = r.nextInt();
		int arr[] = r.nextIntArray(n);

		int bits_available[] = new int[21];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= 20; j++) {
				if (isOn(arr[i], j))
					bits_available[j]++;
			}
		}

		int sum = 0;
		for (int i = 0; i < 21; i++) {
			sum += bits_available[i];
		}

		long ans = 0;
		while (sum > 0) {
			long num = 0;
			for (int i = 20; i >= 0; i--) {
				if (bits_available[i] > 0) {
					bits_available[i]--;
					sum--;
					num |= (1L << i);
				}
			}
			ans += (num * num);
		}

		out.print(ans);
		out.close();

	}

	private static void solve5() throws IOException {

		int t = r.nextInt();
		StringBuilder res = new StringBuilder();

		while (t-- > 0) {

			int n = r.nextInt();

			res.append(false).append("\n");
		}

		out.print(res);
		out.close();
	}

	private static void solve6() throws IOException {

		int t = r.nextInt();
		StringBuilder res = new StringBuilder();

		while (t-- > 0) {

			int n = r.nextInt();

			res.append(false).append("\n");
		}

		out.print(res);
		out.close();
	}

	public static void main(String[] args) throws IOException {

//		solve1();

//		solve2();

//		solve3();

		solve4();

//		solve5();

//		solve6();

	}

	static class Reader {

		final private int BUFFER_SIZE = 1 << 12;
		boolean consume = false;
		private byte[] buffer;
		private int bufferPointer, bytesRead;
		private boolean reachedEnd = false;

		public Reader() {
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = 0;
			bytesRead = 0;
		}

		public boolean hasNext() {
			return !reachedEnd;
		}

		private void fillBuffer() throws IOException {
			bytesRead = System.in.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1) {
				buffer[0] = -1;
				reachedEnd = true;
			}
		}

		private void consumeSpaces() throws IOException {
			while (read() <= ' ' && reachedEnd == false)
				;
			bufferPointer--;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead) {
				fillBuffer();
			}
			return buffer[bufferPointer++];
		}

		public String next() throws IOException {
			StringBuilder sb = new StringBuilder();
			consumeSpaces();
			byte c = read();
			do {
				sb.append((char) c);
			} while ((c = read()) > ' ');
			if (consume) {
				consumeSpaces();
			}
			;
			if (sb.length() == 0) {
				return null;
			}
			return sb.toString();
		}

		public String nextLine() throws IOException {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			return str;
		}

		public int nextInt() throws IOException {
			consumeSpaces();
			int ret = 0;
			byte c = read();
			boolean neg = (c == '-');
			if (neg) {
				c = read();
			}
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (consume) {
				consumeSpaces();
			}
			if (neg) {
				return -ret;
			}
			return ret;
		}

		public long nextLong() throws IOException {
			consumeSpaces();
			long ret = 0;
			byte c = read();
			boolean neg = (c == '-');
			if (neg) {
				c = read();
			}
			do {
				ret = ret * 10L + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (consume) {
				consumeSpaces();
			}
			if (neg) {
				return -ret;
			}
			return ret;
		}

		public double nextDouble() throws IOException {
			consumeSpaces();
			double ret = 0;
			double div = 1;
			byte c = read();
			boolean neg = (c == '-');
			if (neg) {
				c = read();
			}
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}
			if (consume) {
				consumeSpaces();
			}
			if (neg) {
				return -ret;
			}
			return ret;
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public int[][] nextIntMatrix(int n, int m) throws IOException {
			int[][] grid = new int[n][m];
			for (int i = 0; i < n; i++) {
				grid[i] = nextIntArray(m);
			}
			return grid;
		}

		public char[][] nextCharacterMatrix(int n) throws IOException {
			char[][] a = new char[n][];
			for (int i = 0; i < n; i++) {
				a[i] = next().toCharArray();
			}
			return a;
		}

		public void close() throws IOException {
			if (System.in == null) {
				return;
			} else {
				System.in.close();
			}
		}
	}

}