Napište kód pro nalezení maximální hodnoty v poli

```python
def find_max(arr):
    max_val = arr[0]
    for i in range(1, len(arr)):
        if arr[i] > max_val:
            max_val = arr[i]
    return max_val

# Example usage
array = [3, 7, 2, 9, 5]
max_value = find_max(array)
print("Maximum value in the array is:", max_value)
```
[2, 4, 5, 7, 1]
arr = [2, 4, 5, 7, 1]

def findMax(arr):
    max = arr[0]

    for i in range(1, len(arr)):
        if arr[i] > max:
            max = arr[i]
    return max

print(findMax(arr))