Changed static arrays to dynamic arrays and while initialising dynamic array n1 = n1+1 to add sentinel