#K50852. Find Maximum Element in an Array
Find Maximum Element in an Array
Find Maximum Element in an Array
Given an array of integers, your task is to find the maximum element in the array. The input begins with a non-negative integer n which denotes the number of elements in the array, followed by n space-separated integers in the next line. If n = 0, then the program should output The array is empty
.
Mathematically, if the array is represented as \(A = [a_1, a_2, \dots, a_n]\), you need to compute \(\max\{a_1, a_2, \dots, a_n\}\). Ensure to handle the special case when the array is empty.
inputFormat
The first line of input contains an integer n (\(n \ge 0\)), representing the number of elements. The second line contains n space-separated integers.
outputFormat
If n > 0, output a single line with the maximum number among the given integers. If n = 0, output The array is empty
.
5
1 2 3 4 5
5