SOLVE

LATER

Min-Max

Problem

Editorial

Analytics

Given A Series Of **N** Positive Integers a_{1},a_{2},a_{3}........a_{n}. , Find The Minimum And Maximum Values That Can Be Calculated By Summing Exactly **N-1** Of The **N** Integers. Then Print The Respective Minimum And Maximum Values As A Single Line Of Two Space-Separated Long Integers.

**Input Format**

First Line Take Input Value Of **N**

Second Line Take Input **N** Space Separated Integer Value

**Output Format**

Two Space Separated Value ( One Maximum Sum And One Minimum Sum )

**Constraints**

- 0 < N < 100001
- 0 <= a
_{i}< 10^{13}

Explanation

Our initial numbers are 1,2,3,4 and 5. We can calculate the following sums using four of the five integers:

- If we sum everything except 1, our sum is 2+3+4+5=14 .
- If we sum everything except 2, our sum is 1+3+4+5=13 .
- If we sum everything except 3, our sum is 1+2+4+5=12 .
- If we sum everything except 4, our sum is 1+3+4+5=11 .
- If we sum everything except 5, our sum is 1+2+3+4=10 .

As you can see, the minimal sum is 1+2+3+4=10 and the maximal sum is 2+3+4+5=14. Thus, we print these minimal and maximal sums as two space-separated integers on a new line.

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
Bash,
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Swift-4.1,
TypeScript,
Visual Basic

Initializing Code Editor...

{"40f479a": "/pagelets/show-submission/algorithm/min-max-8/", "34b17c3": "/pagelets/problems-hint/algorithm/min-max-8/", "38f1304": "/pagelets/recommended-problems/algorithm/min-max-8/", "871c772": "/pagelets/problem-author-tester/algorithm/min-max-8/"}

realtime.hackerearth.com

80

0ca1ef4c088033244ad4b897270bd9ee359a0f34-realtime