#include <bits/stdc++.h>
using namespace std;
int main() {
int a[10][10] = {0};
int n;
cin >> n;
int num = 1;
int bot = n - 1;
int top = 0;
int left = 0;
int right = n - 1;
while (n * n >= num) {
for (int i = top; i <= bot; i++) {
a[i][right] = num++;
}
right--;
if (top <= bot) {
for (int j = right; j >= left; j--) {
a[bot][j] = num++;
}
bot--;
}
if (right >= left) {
for (int i = bot; i >= top; i--) {
a[i][left] = num++;
}
left++;
}
for (int j = left; j <= right; j++) {
a[top][j] = num++;
}
top++;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << setw(4) << a[i][j];
}
cout << endl;
}
return 0;
}