Java Solution
```\n\n// O(N) Solution\nclass Solution {\n    public List findLonely(int[] nums) {\n        int present[] = new int[1000_001];   // Creating a count array \n  
```\n\n// O(N) Solution\nclass Solution {\n    public List<Integer> findLonely(int[] nums) {\n        int present[] = new int[1000_001];   // Creating a count array \n        for(int i=0;i<nums.length;i++)\n        {\n            present[nums[i]]++;     \n        }\n        List<Integer> ans = new ArrayList<>();\n        if(present[0]==1 && present[1]==0)\n        {\n            ans.add(0);\n        }\n        if(present[1000000]==1 && present[1000000-1]==0)\n        {\n            ans.add(1000000);\n        }\n        for(int i=1;i<present.length-1;i++)\n        {\n            if(present[i]==1 && present[i-1]==0 && present[i+1]==0)\n            {\n                ans.add(i);\n            }\n        }\n        return ans;\n    }\n}
['Array']