you are increasing j to often try creating a for loop with j as well inside the I loop area.

Also lthe length you have should be dynamic based on the length of N or you will never get 4 1's