#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    vector<int> v;
    int n;
    while(cin >> n, n) {
      v.push_back(n);
    }

    sort(v.begin(), v.end());

    int ans = 0, sum = 0;
    for(int i = 0; i < v.size()-1; i++) {
      if(i != 0) ans += sum;
      sum += v[i];
    }
    cout << ans << endl;
}