For this Question: Taro is super small, she has recently learned the skill of walking. She wants to walk on the road from l to r (l < r, l and r must be integers). She cannot walk over a cake.
The road starts from 1 and goes till n (both inclusive). There are m cakes placed on the road at coordinates a[1], a[2],..., a[m].
Please help Taro find the number of ways she can choose l, r. 
Note: She cannot choose l and r such that l <= a[i] <= r, for all values of i from 1 to m.The first line of the input contains two integers n, m.
The next line contains m integers, a[1], a[2], ..., a[m].

(There may be many cakes at the same location)

Constraints
1 <= n <= 2000
0 <= m <= 2000
1 <= a[i] <= nOutput a single integer, the number of distinct (l, r) pairs on which Taro can walk.Sample Input
7 2
3 7  

Sample Output
4

Explanation: The ways of choosing (l, r) pairs are (1, 2), (4, 5), (4, 6), (5, 6)., I have written this Solution Code: import java.io.*;
import java.util.*;



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

         Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int a[] = new int[M];
        long ans=0;
        for(int i=0;i<M;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=1;i<M;i++){
            if(a[i-1] != a[i])
                ans += ((a[i] - a[i-1] - 1)*(a[i] - a[i-1] - 2))/2;
        }
        if(M!=0)
            ans += ((N - a[M-1])*(N - a[M-1] - 1))/2 + ((a[0] - 1)*(a[0] - 2))/2;
        if(M == 0)
            System.out.println(N*(N-1)/2);
        else System.out.println(ans);
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?