import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; class Solution3{ public static void main(String[] args) { // TODO Auto-generated method stub FastReader sc = new FastReader(); int n = sc.nextInt(); int[] arr = new int[n]; for(int i = 0;i < n;i++){ arr[i] = sc.nextInt(); } Arrays.sort(arr); long sum = 0; for(int i = 0;i < arr.length;i++){ sum += arr[arr.length - 1 - i] * Math.pow(2,i); } System.out.println(sum); } static class Bst { static class BstNode{ private int data; private BstNode left; private BstNode right; public int getData(){ return this.data; } public BstNode getLeft(){ return this.left; } public BstNode getRight(){ return this.right; } public void setData(int data){ this.data = data; } public void setLeft(BstNode left){ this.left = left; } public void setRight(BstNode right){ this.right = right; } } /* Main operations in Binary search trees * Find/Find Maximum/Find Minimum * Inserting an elemeent in BST * Deleting an element in BST */ //finding an element public BstNode find(BstNode root,int data){ if(root == null || root.getData() == data){ return root; } if(root.getData() > data){ return find(root.left,data); } return find(root.right,data); } //finding MaxElement in BST public BstNode findMax(BstNode root){ if(root == null){ return root; } while(root.getRight() != null){ root = root.getRight(); } return root; } //finding MinElement in BST public BstNode findMin(BstNode root){ if(root == null){ return root; } while(root.getLeft() != null){ root = root.getLeft(); } return root; } //Inserting an element in Binary Search Tree public BstNode insert(BstNode root,int data){ if(root == null){ root = new BstNode(); root.setData(data); root.setLeft(null); root.setRight(null); } else{ if(root.getData() > data){ root.setLeft(insert(root.getLeft(),data)); } else if(root.getData() <= data){ root.setRight(insert(root.getRight(),data)); } } return root; } //Deleting an element in Binary Search Tree public BstNode Delete(BstNode root,int data){ BstNode temp; if(root == null){ return null; } else if(root.getData() > data){ root.left = Delete(root.getLeft(),data); } else if(root.getData() < data){ root.right = Delete(root.getRight(),data); } else{ //Found element if(root.getLeft() != null && root.getRight() != null){ //The root has two children temp = findMax(root.left); root.setData(temp.getData()); root.setLeft(Delete(root.getLeft(),root.getData())); } else{ //One child temp = root; if(root.getLeft() == null){ root = root.getRight(); } if(root.getRight() == null){ root = root.getLeft(); } } } return root; } //LCA- Lowest Common Ancestor public BstNode lca(BstNode node, int n1, int n2) { if (node == null) return null; // If both n1 and n2 are smaller than root, then LCA lies in left if (node.data > n1 && node.data > n2) return lca(node.left, n1, n2); // If both n1 and n2 are greater than root, then LCA lies in right if (node.data < n1 && node.data < n2) return lca(node.right, n1, n2); return node; } //InOrder Traversal public void inOrder(BstNode root){ if(root != null){ inOrder(root.getLeft()); System.out.println(root.data); inOrder(root.getRight()); } } public int treeHeight(BstNode root){ if(root==null) return 0; return (1+ Math.max(treeHeight(root.left),treeHeight(root.right))); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }