#K85627. Highest and Lowest Temperatures

    ID: 36684 Type: Default 1000ms 256MiB

Highest and Lowest Temperatures

Highest and Lowest Temperatures

You are given the temperatures recorded over a week. Write a program that reads the temperature recordings and outputs the highest temperature and the lowest temperature of the week.

The input will consist of an integer n denoting the number of temperature recordings (which should be 7 for a week). This is followed by n tokens representing the temperatures. If n is 0, if the input is "None", or if any of the tokens is not a valid integer, your program should output None.

All valid inputs will have exactly 7 integer temperature values. The output for valid input should have the highest temperature first and the lowest temperature second, separated by a space.

Note: If any token is non-integer (e.g., float or alphabet), the input is considered invalid.

inputFormat

The input is read from stdin and follows the format:

  • The first line contains an integer n representing the number of temperature recordings.
  • If n is greater than 0, the second line contains n tokens separated by spaces, each representing a temperature.
  • If the input is invalid, it might be the literal string "None" or n can be 0.

outputFormat

If the input is valid, print the highest temperature and the lowest temperature separated by a space on a single line to stdout.

If the input is invalid, print None (without quotes).

## sample
7
23 21 19 22 21 25 26
26 19