Given is a $n\times n$ grid with all squares on one diagonal being forbidden. You are allowed to start from any square, and move one step horizontally, vertically or diagonally. You are not allowed to visit a forbidden square or previously visited square. Your goal is to visit all non forbidden squares. Find, with proof, the minimum number of times you will have to move one step diagonally
1. **Coloring the Grid:**
   - Color the cells of the \( n \times n \) grid in a checkerboard pattern, with alternating black and white cells. This means that any two adjacent cells (horizontally or vertically) will be of different colors, while any two diagonally adjacent cells will be of the same color.

2. **Forbidden Diagonal:**
   - The main diagonal of the grid is forbidden. This means that for an \( n \times n \) grid, there are \( n \) forbidden cells.

3. **Counting Black and White Cells:**
   - Let \( W \) be the number of white cells and \( B \) be the number of black cells in the grid excluding the forbidden diagonal.
   - For an even \( n \):
     - The grid has an equal number of black and white cells, but the forbidden diagonal will have \( \frac{n}{2} \) black cells and \( \frac{n}{2} \) white cells.
     - Thus, \( W = B = \frac{n^2 - n}{2} \).
   - For an odd \( n \):
     - The grid will have one more cell of one color than the other. The forbidden diagonal will have \( \frac{n-1}{2} \) black cells and \( \frac{n+1}{2} \) white cells (or vice versa).
     - Thus, \( W = \frac{n^2 - n + 1}{2} \) and \( B = \frac{n^2 - n - 1}{2} \).

4. **Difference in Number of Cells:**
   - Let \( A \) be the positive difference between the number of white and black cells in the grid excluding the forbidden diagonal.
   - For even \( n \), \( A = 0 \).
   - For odd \( n \), \( A = 1 \).

5. **Movement Constraints:**
   - In any horizontal or vertical move, the two cells will be of different colors.
   - In any diagonal move, the two cells will be of the same color.

6. **Balancing the Colors:**
   - To visit all non-forbidden cells, the total number of black and white cells lying on a horizontal or vertical segment of the path will be the same.
   - Since there are extra \( A \) white cells (assuming white cells are in excess), these cells will lie on some diagonal segment of the path.

7. **Minimum Diagonal Moves:**
   - Therefore, there must be at least \( A - 1 \) diagonal moves to balance the excess cells.
   - For even \( n \), \( A = 0 \), so no diagonal moves are needed.
   - For odd \( n \), \( A = 1 \), so at least \( 1 - 1 = 0 \) diagonal moves are needed.

8. **General Case:**
   - The minimum number of diagonal moves required is \( 2\lfloor\frac{n}{2}\rfloor - 1 \).

The final answer is \( \boxed{ 2\lfloor\frac{n}{2}\rfloor - 1 } \).