finished A1

debugged the insert at rank function