public class Main {
public static void main(String[] args) {
int[][] arr = new int[][]{
{0, 2, 0, 0, 8},
{2, 0, 7, 0, 4},
{0, 7, 0, 3, 5},
{0, 0, 3, 0, 6},
{8, 4, 5, 6, 0}};
int Min = arr[0][0];
for (int i = 0; i < 5; i++){
for (int j = 0; j < 5; j++) {
if ((arr[i][j] != 0) && (arr[i][j] < Min) ) Min = arr[i][j];
}}
System.out.println(Min);
}
}
int min;
int nextI, nextJ
for (int i = 0; i < 5; i++){
for (int j = 0; j < 5; j++) {
if (arr[i][j] != 0) min = arr[i][j];
nextI = i;
nextJ = j;
}
}
if (nextI == 4) {
nextI = 0;
nextJ++;
} else {
nextI++;
}
for (int i = nextI; i < 5; i++){
for (int j = nextJ; j < 5; j++) {
if (arr[i][j] != 0 && arr[i][j] < min) min = arr[i][j];
}
}