C++ solution with detailed comments. 
\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        long long maxReach = 0;\n        int patch = 0;\n        int S = nums.size(
```\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        long long maxReach = 0;\n        int patch = 0;\n        int S = nums.size();\n        \n        // traverse the array while maintaining the maxRead - the furthest number we can generate/\n        // from the given numbers\n        for(int i = 0; maxReach < n;){\n            \n            // if the next number is already covered by the range [1.. maxReach]\n            // or it is just one passed maxReach we can add it to our total sum \n            // to create a new maxReach range. \n            if(i < S && nums[i] <= maxReach + 1){\n                maxReach += (long long)nums[i];\n                i++;\n            }else{\n                // if the next number is passed maxReach + 1 (or we have exhausted our array)\n                // we should add a new number to our range (e.g. patch) and then this new number \n                // effecitvely increases our ranges. By how much? we just need to add it to our range\n                // to get a new range (which means that it doubles our range + 1)\n                patch++;\n                maxReach = maxReach*2 + 1;\n            }\n        }\n\t\t\t\t\n        return patch;\n    }\n};\n```
[]