func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let _ = Int(readLine()!)!
    
    let a = readInts().sorted()
    
    let val = a.reduce(0) { $0 + $1 } - a[0]
    
    print(val)
}

main()
