int main() {
    int n;
    scanf("%d", &n);
    int val[n][n], count = 1;
    int x = 0, y = n - 1;
    while (count != n * n + 1) {
        for (int i = x; i <= y; i++) //上行循环
            val[x][i] = count++;
        for (int i = x + 1; i <= y; i++)  //后列循环
            val[i][y] = count++;
        for (int i = y - 1; i >= x; i--) //下行循环
            val[y][i] = count++;
        for (int i = y - 1; i >= x + 1; i--) //前列循环
            val[i][x] = count++;
        x++;  //行加1
        y--;  //列减1
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            printf("%d ", val[i][j]);
        }
        printf("\n");
    }
    return 0;
}