public static TreeNode maxTree1(int[] A) {
        // write your code here
        int n=A.length;
        for (int i=(n-1)/2;i>=0;--i)
            heapify(A,i);
        Queue<TreeNode>q=new ArrayDeque<>();
        TreeNode root=new TreeNode(A[0]);
        q.offer(root);
        int i=1;
        while (!q.isEmpty()&&i<n) {
            for (int m=q.size(),j=0; j<m;++j) {
                TreeNode node=q.poll();
                if (i<n)
                    q.offer(node.left=new TreeNode(A[i++]));
                else 
                    break;
                if (i<n)
                    q.offer(node.right=new TreeNode(A[i++]));
                else
                    break;
            }
        }
        return root;
    }