What is wrong with my code?

@mayank10
make these changes your code will work

  1. line 12 you should check only for lesser value not for equal value. So change line 12 to if(a[i]<a[j])
  2. increment i after count+=(e-j+1)*a[i]; operation. So delete i++ from line 15 and write after line 16.
  3. use long long int.
  4. to pass all testcases you have to print final ans %1000000007.