For this Question: Tom has N sticks that are distinguishable from each other. The length of the i-th stick is L[i]. He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:

a < b+c
b < c+a
c < a+b

How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.The first line of input contains the number of sticks N, the next line contain N space separated integer where the ith integer shows the length of ith stick.

Constraints:-
3 ≤ N ≤ 1000
1 ≤ L[i] ≤ 1000Print the number of different triangles that can be formed.Sample Input 1 
4
3 4 2 1

Sample Output 1 
1

Sample Input 2
3
1 1000 1

Sample Output 2
0

Explanation:
For sample test case 1 the only triangle that can be formed is 2 3 4
, I have written this Solution Code: import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
	public static void main (String[] args) {
                      // Your code here
		Scanner sc = new Scanner(System.in);
		int arrSize = sc.nextInt();
		int arr[] = new int[arrSize];

		for(int i = 0; i < arrSize; i++)
			arr[i] = sc.nextInt();

		System.out.println(countTri(arr, arrSize));
	}

	static long countTri(int arr[], int arrSize)
	{
		   Arrays.sort(arr);
			long cnt=0;
			for(int i=0;i<arrSize-2;i++)
			{
				
				int j=i+1;
		        int k=i+2;
				while(k!=arrSize){
						if(arr[j]+arr[i]<=arr[k]){if(j>=k-1){k++;}
							else{j++;}
							}
						else{
								cnt+=(k-j);
							k++;

						}

				}

		    }
			return cnt;
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?