Language: C++

#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;


int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(), a.end());
    int com=0;
    vector<int> count2(n,0);
    count2.at(0)=a.at(0);
    count2.at(1)=a.at(1);
    com+=a.at(0);

    for (int i = 2; i < 19; i++)
    {
        if(n>=2**i){
            for (int i = 2**(i-1); i < 2**i-1; i++)
            {
                com+=min(count2.at(i-2**(i-1)),count2.at(i-2**(i-1)+1));
            }
            com+=count2.at(2**(i-1)-1);
            for (int i = 2**(i)-1; i > 2**(i-1)-1; i--)
            {
                count2.insert(count2.begin()+i-2**(i-1)+1,a.at(i));
            }            
        }else if(n>2**(i-1))
        {
            for (int i = 2**(i-1); i < n; i++)
            {
                com+=min(count2.at(i-2**(i-1)),count2.at(i-2**(i-1)+1));
            }
            cout<<com<<endl;
        }



    }

    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: invalid type argument of unary '*' (have 'int')
   32 |         if(n>=2**i){
      |                 ^~
a.cc:33:28: error: invalid type argument of unary '*' (have 'int')
   33 |             for (int i = 2**(i-1); i < 2**i-1; i++)
      |                            ^~~~~~
a.cc:33:42: error: invalid type argument of unary '*' (have 'int')
   33 |             for (int i = 2**(i-1); i < 2**i-1; i++)
      |                                          ^~
a.cc:35:40: error: invalid type argument of unary '*' (have 'int')
   35 |                 com+=min(count2.at(i-2**(i-1)),count2.at(i-2**(i-1)+1));
      |                                        ^~~~~~
a.cc:35:62: error: invalid type argument of unary '*' (have 'int')
   35 |                 com+=min(count2.at(i-2**(i-1)),count2.at(i-2**(i-1)+1));
      |                                                              ^~~~~~
a.cc:37:30: error: invalid type argument of unary '*' (have 'int')
   37 |             com+=count2.at(2**(i-1)-1);
      |                              ^~~~~~
a.cc:38:28: error: invalid type argument of unary '*' (have 'int')
   38 |             for (int i = 2**(i)-1; i > 2**(i-1)-1; i--)
      |                            ^~~~
a.cc:38:42: error: invalid type argument of unary '*' (have 'int')
   38 |             for (int i = 2**(i)-1; i > 2**(i-1)-1; i--)
      |                                          ^~~~~~
a.cc:40:50: error: invalid type argument of unary '*' (have 'int')
   40 |                 count2.insert(count2.begin()+i-2**(i-1)+1,a.at(i));
      |                                                  ^~~~~~
a.cc:42:22: error: invalid type argument of unary '*' (have 'int')
   42 |         }else if(n>2**(i-1))
      |                      ^~~~~~
a.cc:44:28: error: invalid type argument of unary '*' (have 'int')
   44 |             for (int i = 2**(i-1); i < n; i++)
      |                            ^~~~~~
a.cc:46:40: error: invalid type argument of unary '*' (have 'int')
   46 |                 com+=min(count2.at(i-2**(i-1)),count2.at(i-2**(i-1)+1));
      |                                        ^~~~~~
a.cc:46:62: error: invalid type argument of unary '*' (have 'int')
   46 |                 com+=min(count2.at(i-2**(i-1)),count2.at(i-2**(i-1)+1));
      |                                                              ^~~~~~