for(int i=a;i>0;i–){
ans = abs(arr[i]-arr[i-1]);
}
cout << ans << “\n”;
what’s the final thing this loop does? When i is 1, it calculates the absolute difference between a[1] and a[0]. Since a is sorted, these are the two smallest elements in the array.
How does that give the required answer? It doesn’t.