Most variables you define are short integers. When the data exceeds 32767, it will overflow. Change% to&; It won't be a problem.
Dim d,i & ampj & amp,k & amp,arr,brr(),a & amp,c & amp,l & amp