Maybe the trickiest part is the creation of A:
A:=Matrix(n,n,(i,j) -> piecewise(i=j,0,1));
as this is not well documented. Then it is smooth sailing using the LinearAlgebra package:
Read the docs for the LinearAlgebra package to understand how to use it.
One deficiency of Maple is that it does not deal with abstract matrices (or vectors, for that matter) of arbitrary dimension. I.e. n has to be defined, else the Matrix constructor throws an error. So you will need to write a loop or otherwise solve the problem explicitly for the 3 cases.