working for n=10.  need to figure out how to change value for n to 100, 1000 and 10000. maybe loop through array.length