import java.io.*;
class Main {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int N = Integer.parseInt(br.readLine());
for (int i = 0; i < N - 1; i++) {
for (int j = N - 1; j > i; j--) {
sb.append(" ");
}
for (int k = 0; k <= (i * 2); k++) {
sb.append("*");
}
sb.append("\n");
}
for (int i = N - 1; i >= 0; i--) {
for (int j = N - 1; j > i; j--) {
sb.append(" ");
}
for (int k = 0; k <= (i * 2); k++) {
sb.append("*");
}
sb.append("\n");
}
System.out.println(sb);
}
}
해결방법