#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long fceil(long long a, long long b) {
  return (a % b == 0 ? a / b : a / b + 1);
}
int main() {
  long long n, a[100007] = {}, sum = 0, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 0; i < n; i++) ans = max(ans, sum - a[i]);
  cout << ans << endl;
  return 0;
}
