taking n as input