import java.util.Scanner;
public class invertedhourglass {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n =sc.nextInt();
int nst =1;
int nsp=2*n-1;
int nr=2*n+1;
int val1;
int val2;
//row
int row=1;
while( row<=nr)
{
val1=5;
val2=1;
for (int cst=1;cst<=nst;cst++){
if(cst<=nst){
System.out.print(val1-- + " ");
}
}
for (int csp=1;csp<=nsp;csp++){
System.out.print(" ");
}
int cst=1;
if (row==n+1){
cst=2;
}
for (;cst<=nst;cst++){
if(cst<=nst){
System.out.print(val2++ + " ");
}
}
System.out.println();
if(row<=nr/2){
nst=nst+1;
nsp=nsp-2;
}
else{
nst=nst-1;
nsp=nsp+2;
}
row=row+1;
}
}
}
not able to update val in second side of the pattern. Please help