#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

vector<int> vec;
int n;
int t;

int main(){
	while(cin>>n,n){
		vec.clear();
		int res=0;
		rep(i,n){
			cin>>t;
			vec.PB(t);
		}
		sort(ALL(vec));
		//rep(i,n) cout<<vec[i]<<endl;
		rep(i,n-1) res=res+vec[i];
		cout<<res<<endl;
		
	}
	return 0;
}