Given an integer `n`, return the number of distinct ways to place n queens on an n x n chessboard so that no two queens attack each other (no shared row, column, or diagonal).