sort and use prefix sum c++
stop when there is a gap.\n\n    int getMaximumConsecutive(vector<int>& coins) {\n        sort(begin(coins),end(coins));\n        int n=coins.size();\n        i
stop when there is a gap.\n```\n    int getMaximumConsecutive(vector<int>& coins) {\n        sort(begin(coins),end(coins));\n        int n=coins.size();\n        int mx=0,pre=0;\n        for(int i: coins){\n            if(i>pre+1) return pre+1;\n            pre+=i;\n        }\n        return pre+1;\n    }\n```
[]