Select corner points of a grid with only one value (number of rows or columns)?
In any case, you must know (or find out) the number of rows/columns.
With this value you can separate the rows/columns that lie between the first and the last.
Then you need the index sequence of a row (from 0 to $n$ or the first and last point in your row). You do this with the Math Node and the mathematical operator Modulo.
With greater/less than you get the points between the first and last point of all rows.
If you now combine this selection with the previous one and filter out the points that are not present in either of these selections, you will get exactly the vertices of your grid.
And here is another interesting variant:
If you use Ping-Pong and use half the number of points as Scale, you also get useful numbers for a grid with which you only have to compare the number of points of a row: