Generic method for finding the maximum in an array

Java Easy generics

Task «Generic method for finding the maximum in an array»

Implement a generic method maxElement that takes an array of elements of type T (where T extends Comparable<T>) and returns the maximum element. If the array is empty, the method should return null. It is guaranteed that all elements are not null.

Input Format

First line: integer N (1 ≤ N ≤ 100). Second line: N elements separated by spaces. Elements can be integers or strings.

Output Format

One line: maximum element of the array. If the array is empty, output "null".

Examples

Example 1

INPUT
5 3 7 2 9 1
OUTPUT
9

Example 2

INPUT
4 apple banana cherry date
OUTPUT
date

Example 3

INPUT
0
OUTPUT
null
main.java