Question: Array 2 indecies problem

hello, For the P, and A arrays which depend on i,j, it always gives me index out of range i dont know whats wrong, any help, and thank you
 

 

restart

N:=4000;
g:=Array(0..N):
g[0]:=0:
g[1]:=-2.47:
g[2]:=-2.33:
g[3]:=0.205:
g[4]:=2.99:
g[5]:=2.66:
g[6]:=2.65:
g[7]:=2.59:
g[8]:=2.5:
g[9]:=2.42:
g[10]:=2.37:
g[11]:=2.37:
g[12]:=2.39:
g[13]:=2.42:
g[14]:=2.43:
g[15]:=2.42:
g[16]:=2.4:
g[17]:=2.39:
g[18]:=2.39:
g[19]:=2.39:
g[20]:=2.38:
g[21]:=2.37:
g[22]:=2.36:
g[23]:=2.35:
g[24]:=2.34:
g[25]:=2.34:
g[26]:=2.34:
g[27]:=2.35:
g[28]:=2.37:
g[29]:=2.38:
g[30]:=2.4:
g[31]:=2.41:
g[32]:=2.41:
g[33]:=2.4:
g[34]:=2.4:
g[35]:=2.4:
g[36]:=2.4:
g[37]:=2.4:
g[38]:=2.39:
g[39]:=2.36:
g[40]:=2.32:
g[41]:=2.29:
g[42]:=2.29:
g[43]:=2.35:
g[44]:=2.44:
g[45]:=2.53:
g[46]:=2.61:
g[47]:=2.68:
g[48]:=2.69:
g[49]:=2.59:
g[50]:=2.38:
g[51]:=2.13:
g[52]:=1.89:
g[53]:=1.68:
g[54]:=1.52:
g[55]:=1.55:
g[56]:=1.83:
g[57]:=2.26:
g[58]:=2.57:
g[59]:=2.56:
g[60]:=2.31:
g[61]:=2.12:
g[62]:=2.14:
g[63]:=2.36:
g[64]:=2.67:
g[65]:=2.94:
g[66]:=3.14:
g[67]:=3.27:
g[68]:=3.26:
g[69]:=3.03:
g[70]:=2.66:
g[71]:=2.41:
g[72]:=2.4:
g[73]:=2.55:
g[74]:=2.7:
g[75]:=2.75:
g[76]:=2.7:
g[77]:=2.54:
g[78]:=2.24:
g[79]:=1.84:
g[80]:=1.4:
g[81]:=0.959:
g[82]:=0.488:
g[83]:=-0.0341:
g[84]:=-0.501:
g[85]:=-0.776:
g[86]:=-0.866:
g[87]:=-0.959:
g[88]:=-1.28:
g[89]:=-1.9:
g[90]:=-2.68:
g[91]:=-3.42:
g[92]:=-3.84:
g[93]:=-3.72:
g[94]:=-3.22:
g[95]:=-2.66:
g[96]:=-2.26:
g[97]:=-1.99:
g[98]:=-1.73:
g[99]:=-1.38:
g[100]:=-1.14:
g[101]:=-1.3:
g[102]:=-1.92:
g[103]:=-2.8:
g[104]:=-3.81:
g[105]:=-4.84:
g[106]:=-5.75:
g[107]:=-6.53:
g[108]:=-7.28:
g[109]:=-8.12:
g[110]:=-8.86:
g[111]:=-9.17:
g[112]:=-8.96:
g[113]:=-8.51:
g[114]:=-7.96:
g[115]:=-7.17:
g[116]:=-6.13:
g[117]:=-5.21:
g[118]:=-4.77:
g[119]:=-4.31:
g[120]:=-2.46:
g[121]:=1.47:
g[122]:=6.76:
g[123]:=12:
g[124]:=15.4:
g[125]:=15.6:
g[126]:=13.2:
g[127]:=10.4:
g[128]:=8.38:
g[129]:=7.39:
g[130]:=6.55:
g[131]:=5.13:
g[132]:=3.07:
g[133]:=0.816:
g[134]:=-1.26:
g[135]:=-3.08:
g[136]:=-4.81:
g[137]:=-6.62:
g[138]:=-8.57:
g[139]:=-10.8:
g[140]:=-13.3:
g[141]:=-16.2:
g[142]:=-19.4:
g[143]:=-22.5:
g[144]:=-25.6:
g[145]:=-28.7:
g[146]:=-31.9:
g[147]:=-34.4:
g[148]:=-34.6:
g[149]:=-32:
g[150]:=-27.9:
g[151]:=-24.1:
g[152]:=-21.2:
g[153]:=-19.9:
g[154]:=-20.4:
g[155]:=-21.8:
g[156]:=-22.9:
g[157]:=-22.8:
g[158]:=-21.8:
g[159]:=-20.8:
g[160]:=-20.8:
g[161]:=-22.4:
g[162]:=-25.1:
g[163]:=-28.1:
g[164]:=-30.5:
g[165]:=-29.5:
g[166]:=-19.3:
g[167]:=1.66:
g[168]:=28:
g[169]:=51.6:
g[170]:=64.3:
g[171]:=63.9:
g[172]:=56.7:
g[173]:=50.9:
g[174]:=50.1:
g[175]:=52.3:
g[176]:=54:
g[177]:=53.3:
g[178]:=51.1:
g[179]:=49.5:
g[180]:=49.7:
g[181]:=50.9:
g[182]:=52.3:
g[183]:=53.3:
g[184]:=53.9:
g[185]:=53.7:
g[186]:=51.7:
g[187]:=47.8:
g[188]:=43:
g[189]:=38.4:
g[190]:=34.5: