Write a Java program to remove duplicates from an array. The input array is given as [50, 11, 33, 21, 40, 50, 40, 40, 21]. After removing duplicates, the array should be [11, 21, 33, 40, 50]. The program should adhere to the following requirements:
- Do not use LiBrary functions for sorting or removing duplicates.
- Implement the solution with O(n log2(n)) time complexity overall and O(n) space complexity.
- Use the Merge Sort algorithm for sorting the array.
- The de-duplication part should have O(n) time complexity and O(1) space complexity.
- Prompt the user to input the size of the array and the integers in the array.
- Handle the following scenarios:
- If the input array is null or empty, prompt the user saying the array is empty or null.
- If the input is not a valid integer, prompt the user and do not abruptly exit the program.
- Avoid throwing NullPointerException or ArrayIndexOutOfBoundsException while looping through the input array.

Please explain the sorting algorithm and de-duplication algorithm in comments while you code. Also, write test cases in comments.