For this Question: You are given an array with all distinct elements which include all elements of a binary search tree in an increasing order manner (in-order traversal). But 2 element swapped their position. we have to print the sum of two swapped nodes.The first line contains a single integer N.
The second line contains N space-separated integer A[i].
Print sum of exchanged node value.Sample Input 1:
1 2 3 4 5 7 6

Sample Output 1:
13


Explanations:
if we draw a BST from given array than we can observe that element 6 and 7 had swapped their position.
So sum of these 2 is equal to 13., I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[n];

        String[] strNums;
        strNums = br.readLine().split(" ");
        arr[0] = Integer.parseInt(strNums[0]);
        int count = 0;

        for(int i = 1; i < n; i++){
            int val = Integer.parseInt(strNums[i]);
            arr[i] = val;
            if(arr[i-1] > arr[i]) count++;
        }

        int ans = 0;

        if(count > 1){

            int a = -1;
            int b = -1;

            for(int i = 1; i < n; i++){

                if(arr[i-1] > arr[i] && a == -1){
                    a = arr[i-1];
                }
                else if(arr[i-1] > arr[i]){
                    b = arr[i];
                }
            }
            ans = a + b;
        }
        else{
            for(int i = 1; i < n; i++){

                if(arr[i-1] > arr[i]){
                    ans = arr[i-1] + arr[i];
                }
            }
        }

        System.out.print(ans);
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?