Given an array A[] containing n distinct numbers taken from 0, 1, 2, 3, 4,.....n , write a program to find the one that is missing from the array.

Problem Note: Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity?

Example 1

Input: A[] = [3,0,1]
Output: 2

Example 2

Input: A[] = [9,6,4,2,3,5,7,0,1]
Output: 8

Example 3

Input: A[] = [5,4,1,2,3]
Output: 0

NOTE: There will be only one missing number in the given array, two missing numbers will not be there. Also, if there is no missing number then you have to return the number that is coming just after the largest element of the array.