#include //min/max/sort(rand-access it)/merge #include #include // #include //std::chrono::/system_clock/steady_clock/high_resolution_clock/duration #include //INT_MAX/INT_MIN/ULLONG_MAX #include //fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc // #include //printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets #include //abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort // #include //ifstream/ofstream #include //setfill/setw/setprecision/fixed/scientific #include //cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific #include #include //numeric_limits::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN #include #include #include #include //stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline #include #include //pair #include #include #define PRIME_SHORT 10007 #define PRIME 1000000007 using namespace std; typedef unsigned int ui; typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef pair plli; typedef pair puli; typedef pair pdi; typedef pair pllll; typedef pair pulul; typedef pair pdd; typedef tuple ti3; typedef tuple ti4; const bool debug = false; template void rar(size_t n, T* a); template void rar2(size_t n, size_t m, T** a); template T ipow(T base, T exp); inline size_t left(size_t current, bool swap = false); inline size_t right(size_t current, bool swap = false); template inline T griddist(T x, T y, T s, T t); template inline T griddist(pair one, pair two); template inline T griddist(tuple one, tuple two); template inline T sqeucldist(T x, T y, T s, T t); template inline T sqeucldist(pair one, pair two); template inline T sqeucldist(tuple one, tuple two); inline ull modadd(ull a, ull b, int mod); inline ull modmult(ull a, ull b, int mod); int main(void) { ull n; cin >> n; ull j = 1UL; ull mil = 0UL; vector cal; for (size_t i = 0; i < n; ++i) { ull temp; cin >> temp; cal.push_back(temp); } sort(cal.begin(), cal.end(), greater()); for (size_t i = 0; i < n; ++i) { mil += cal[i]*j; j *= 2UL; } cout << mil << endl; return 0; } template void rar(size_t n, T* a) { for (size_t i = 0; i < n; ++i) cin >> a[i]; return; } template void rar2(size_t n, size_t m, T** a) { for (size_t i = 0; i < n; ++i) { a[i] = new int[m]; for (size_t j = 0; j < m; ++j) cin >> a[i][j]; } return; } template T ipow(T base, T exp) { T result = 1; while (exp) { if (exp & 1) result *= base; exp >>= 1; base *= base; } return result; } inline size_t left(size_t current, bool swap) { return swap ? right(current) : 2*current+1; } inline size_t right(size_t current, bool swap) { return swap ? left(current) : 2*(current+1); } template inline T griddist(T x, T y, T s, T t) { return abs(x-s) + abs(y-t); } template inline T griddist(pair one, pair two) { return abs(one.first - two.first) + abs(one.second - two.second); } template inline T griddist(tuple one, tuple two) { return abs(get<0>(one) - get<0>(two)) + abs(get<1>(one) - get<1>(two)); } template inline T sqeucldist(T x, T y, T s, T t) { T a = x-s; T b = y-t; return a*a+b*b; } template inline T sqeucldist(pair one, pair two) { T a = one.first - two.first; T b = one.second - two.second; return a*a+b*b; } template inline T sqeucldist(tuple one, tuple two) { T a = get<0>(one) - get<0>(two); T b = get<1>(one) - get<1>(two); return a*a+b*b; } inline ull modadd(ull a, ull b, int mod) { return ((a%mod) + (b%mod))%mod; } inline ull modmult(ull a, ull b, int mod) { return ((a%mod)*(b%mod))%mod; }