#include <bits/stdc++.h>
using namespace std;
int main() {
int a1010 = {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++) {
airight = num++;
}
right--;
if (top <= bot) {
for (int j = right; j >= left; j--) {
abotj = num++;
}
bot--;
}
if (right >= left) {
for (int i = bot; i >= top; i--) {
aileft = num++;
}
left++;
}
for (int j = left; j <= right; j++) {
atopj = num++;
}
top++;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << setw(4) << aij;
}
cout << endl;
}
return 0;
}