#include #include #include #define MOD 1000000007 #define MODSET(d) if ((d) >= MOD) d %= MOD; #define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD; #define MODADDSET(d) if ((d) >= MOD) d -= MOD; #define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD; #define cint(d) scanf("%d", &d) #define cint2(a, b) scanf("%d %d", &a, &b) #define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c) #define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d) #define clong(d) scanf("%lld", &d) #define clong2(a, b) scanf("%lld %lld", &a, &b) #define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c) #define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d) #define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin(); v != (c).end(); ++v) #define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin(); v != (c).rend(); ++v) #define ALL(v) (v).begin(), (v).end() #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; #ifdef VSP4 //Debugging Template Author: Nikhil Garg #define debug(args...) cout << "Line No = " << __LINE__ << " >\t"; (Debugger()) , args class Debugger { public: Debugger(const std::string& _separator = ", ") : first(true), separator(_separator){} template Debugger& operator , (const ObjectType& v) { if(!first) std::cout << separator; std::cout << v; first = false; return *this; } ~Debugger() { std::cout << endl;} private: bool first; std::string separator; }; template inline std::ostream& operator << (std::ostream& os, const std::pair& p) { return os << "(" << p.first << ", " << p.second << ")"; } template inline std::ostream &operator << (std::ostream & os,const std::vector& v) { bool first = true; os << "["; for(unsigned int i = 0; i < v.size(); i++) { if(!first) os << ", "; os << v[i]; first = false; } return os << "]"; } template inline std::ostream &operator << (std::ostream & os,const std::set& v) { bool first = true; os << "["; for (typename std::set::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if(!first) os << ", "; os << *ii; first = false; } return os << "]"; } template inline std::ostream &operator << (std::ostream & os,const std::map& v) { bool first = true; os << "["; for (typename std::map::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if(!first) os << ", "; os << *ii ; first = false; } return os << "]"; } #else #define debug(args...) // Just strip off all debug tokens #endif typedef long long int slong; typedef pair pii; typedef pair pll; typedef tree, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set::iterator sit; typedef map::iterator mit; typedef vector::iterator vit; const int MAXN = 1e3; const int SQRTN = 400; const int LOGN = 16; const int INT_INFINITY = 1001001001; const slong LONG_INFINITY = 2001001001001001001ll; const double EPS = 1e-6; const int LIMIT = 1e3; int n; int c[MAXN+5]; int main() { #ifdef VSP4 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif cout.tie(0); int t, i, j, d; //cint(t); //while (t--) { cint(n); for (i = 1; i <= n; i++) { cint(c[i]); } sort(c+1, c+n+1, greater()); slong ans = 0; for (i = 1; i <= n; i++) { ans += powl(2, i-1)*c[i]; } cout << ans << "\n"; } return 0; }