Fast solution O(N*logN) time and O(1) space
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(N*log N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public:\n  int getMaximumConsecutive ( vector<int>& a ) {\n    int ans = 1 , k = 0;\n    sort ( a.begin ( ) , a.end ( ) );\n    for ( auto&& i : a ) {\n      if ( i - k <= 1 ) {\n        k += i;\n        if ( i != k + 1 )  ans += i;\n        else ++ans;\n        }\n      }\n    return ans;\n    }\n  };\n```
['C++']