<s>[INST] import java.util.*;

public class Solution {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] nums = new int[n];
		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		Arrays.sort(nums);
		System.out.println(nums[n-1]);
	}
}

This program sorts an array using built-in `Arrays.sort()` method and then prints the largest element which is at the end of the sorted array (`nums[n-1]`). But I want to do it without using built-in sort functions. How can I modify this code?[/INST]