You have an $n\times n$ grid and want to remove all edges of the grid by the sequence of the following moves. In each move, you can select a cell and remove exactly three edges surrounding that cell; in particular, that cell must have at least three remaining edges for the operation to be valid. For which positive integers $n$ is this possible?
1. **Counting the Edges:**
   - An \( n \times n \) grid has \( n \) rows and \( n \) columns.
   - Each row has \( n+1 \) vertical edges, and each column has \( n+1 \) horizontal edges.
   - Therefore, the total number of edges in the grid is:
     \[
     2n(n+1)
     \]
   - Since each move removes exactly 3 edges, the total number of edges must be divisible by 3. Hence:
     \[
     2n(n+1) \equiv 0 \pmod{3}
     \]
   - This implies:
     \[
     n(n+1) \equiv 0 \pmod{3}
     \]
   - Since \( n \) and \( n+1 \) are consecutive integers, one of them must be divisible by 3. Therefore:
     \[
     n \equiv 0 \pmod{3} \quad \text{or} \quad n \equiv 2 \pmod{3}
     \]

2. **Considering Even and Odd \( n \):**
   - We need to show that \( n \) cannot be even. Suppose \( n \) is even, then \( n = 2k \) for some integer \( k \).
   - We will use a contradiction approach to show that \( n \) cannot be even.

3. **Type \( A \) and \( B \) Cells:**
   - Define a cell as type \( A \) if a move has been made on that cell, and type \( B \) otherwise.
   - From each type \( A \) cell, draw an arrow to the adjacent cell whose common edge is not removed by the move on that cell.

4. **Properties of Type \( A \) Cells:**
   - All of the \( 4n-4 \) bordering cells are of type \( A \).
   - Whenever two type \( A \) cells share a common edge, one of them points an arrow towards the other.
   - Since each type \( A \) cell only emits one arrow, the arrows on the boundary cells form a cycle.

5. **Alternating Pattern in the Second Row:**
   - The types of cells in the second row alternate between \( A \) and \( B \).
   - Two type \( B \) cells cannot be adjacent.
   - Suppose the second row contains two adjacent type \( A \) cells. Then, together with the two other type \( A \) cells above, we have four pairs of adjacent type \( A \) cells.
   - The corresponding arrows must form a 4-cycle, which is impossible for \( n > 2 \).

6. **Conclusion for Even \( n \):**
   - Therefore, the second row does not contain two adjacent type \( A \) cells, implying \( n \) must be odd.

7. **Constructing for \( n = 2, 3, 5 \):**
   - The construction for \( n = 2, 3, 5 \) is straightforward.
   - If we have a construction for odd \( n \), we can also construct for \( n + 6 \) by extending the grid and maintaining the pattern.

8. **Final Conclusion:**
   - The possible values of \( n \) are those for which \( n \equiv 3 \) or \( n \equiv 5 \pmod{6} \) for \( n > 2 \), and \( n = 2 \).

The final answer is \( \boxed{ n \equiv 3 } \) or \( n \equiv 5 \pmod{6} \) for \( n > 2 \), and \( n = 2 \).