/**
 * @author pr4shan7 (प्रशांत)
 */
// everything has a cost!

#ifdef _MAVERICK
#define _DEBUG
#else
#pragma GCC optimize("O2")
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC reset_options
#endif

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/math/constants/constants.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace boost::multiprecision;
// using namespace boost::math::constants;

// #define cerr cout
// #define clog cout
// #define int long long
// #define int int_fast32_t
// #define double long double

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef unordered_set<int> usi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;

#define pb push_back
#define x first
#define y second
#define cai static_cast<int>
#define cad static_cast<double>
#define cal static_cast<long long>
#define all(z) z.begin(), z.end()
#define sz(z) static_cast<long>(z.size())
#define fe(cont, itm) for (auto&& itm : cont)
#define rep(in, beg, sz) for (int in = beg; in < sz; in++)
#define rrep(in, sz, beg) for (int in = sz - 1; in >= beg; in--)
#define tr(cont, itr) for (auto itr = cont.begin(); itr != cont.end(); itr++)
#define rtr(cont, itr) for (auto itr = cont.rbegin(); itr != cont.rend(); itr++)

#ifdef _DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
template <typename... T> void debug_out(const T&...);
#else
#define debug(...) 42
#define endl '\n'
#endif

template <typename... T> void scan(T&...);
constexpr void print() {}
template <typename T> void print(const T&);
template <typename Head, typename... Tail> void print(const Head&, const Tail&...);
template <typename... T> void println(const T&...);
template <typename T> istream& operator>>(istream&, vector<T>&);
template <typename T> ostream& operator<<(ostream&, const vector<T>&);
double time_it(const chrono::time_point<chrono::high_resolution_clock>&, const chrono::time_point<chrono::high_resolution_clock>&);
template <typename T> constexpr T pow(long long, long long, const T);

const int INF = 1e9;
const int MV = 1e9 + 7;

// beautiful things don't ask for attention


signed main() {
  const auto start = chrono::high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifdef _MAVERICK
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  freopen("err.txt", "w", stderr);
#endif


  int n; scan(n);
  vi ar(n); scan(ar);
  sort(all(ar),greater<int>());
  debug(ar);
  if (n<2) print(0);
  else if (n==2) print(ar[0]);
  else {
    ll ans = ar[0];
    n -= 2;
    // println(ans,n);
    for (int i = 1; n; i++) {
      ans += ar[i];
      // println(ans,n, ar[i]);
      if(!--n) break;
      ans += ar[i];
      n--;
      // println(ans,n, ar[i]);
    }
    print(ans);
  }


  const auto end = chrono::high_resolution_clock::now();
  time_it(start, end);

  return 0;
}


template <typename... T>
void scan(T&... args) { ((cin >> args), ...); }

template <typename T>
void print(const T& arg) { cout << arg; }

template <typename Head, typename... Tail>
void print(const Head& H, const Tail&... T) { cout << H << ' '; print(T...); }

template <typename... T>
void println(const T&... args) { print(args...); cout << endl; }

#ifdef _DEBUG
template <typename... T>
void debug_out(const T&... args) {
  ((cerr << ' ' << args), ...);
  cerr << '\n';
}
#endif

template <typename T>
istream& operator>>(istream& in, vector<T>& ar) {
  for (T& i : ar) in >> i;
  return in;
}

template <typename T>
ostream& operator<<(ostream& out, const vector<T>& ar) {
  if (!ar.size()) return out;
  for (size_t i = 0; i < ar.size() - 1; i++) out << ar[i] << ' ';
  out << ar[ar.size() - 1];
  return out;
}

inline double time_it(const chrono::time_point<chrono::high_resolution_clock>& start, const chrono::time_point<chrono::high_resolution_clock>& end) {
  chrono::duration<double, milli> time_taken = end - start;
#ifdef _MAVERICK
  clog << "time taken: " << fixed << setprecision(3) << time_taken.count() << " ms" << flush;
#endif
  return time_taken.count();
}

template <typename T>
constexpr T pow(long long a, long long b, const T mv) {
  long long res = 1;
  a %= mv;
  while (b) {
    if (b & 1)
      res = (res * a) % mv;
    b >>= 1;
    a = (a * a) % mv;
  }
  return res;
}

// get busy living or get busy dying

Measured memory_bytes: 4016