#include<bits/stdc++.h> using namespace std; int main(){ int a,b,c=0,d=0; cin>>a; for(int i=1;i<=a;i++){ cin>>b; c+=b; if(b>d){ d=b; } } cout<<c-d; }