Coding Challenge Solution - Good Range
Don't force a class where a function is perfectly fine.
The namespace std is not designed for wholesale importation, see "Why is “using namespace std” considered bad practice?" for more detail.
Identifiers starting with an underscore followed by an uppercase letter are reserved.
Input is generally unreliable. But you don't test for error at all.
Always recomputing the current result from first principles, instead of just updating it with the newest addition, is a waste of time.
Flushing is expensive, so avoid std::endl and explicitly request it with std::flush where unavoidable.
You should probably follow the requested output-format...
You know that int in unsigned int is implicit?
In C++ and C99+, return 0; is implicit for main().
I wonder why you sometimes surround binary operators with space, and sometimes don't.
Having over-long lines is very cumbersome to read. Admittedly, you need not make a hard cut at 79 nowadays.
You should double-check whether duplicate inputs can occurr (there are none in the example), and if so whether they should cause anything but repeated output.
I assumed duplicated possible, and they only cause output.


Duplicates have an effect would destroy ranges instead of adding them, thus needing an ordered std::set.
Duplicates not possible would mean the std::unordered_set can be dispensed with.



#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;unordered_set&gt;

int main() {
    unsigned n, m, x;
    std::cin &gt;&gt; n &gt;&gt; m;
    if (!std::cin || !n) {
        std::cerr &lt;&lt; "Bad Input!\n";
        return EXIT_FAILURE;
    }
    std::unordered_set&lt;unsigned&gt; nums;
    auto r = 0ULL;
    while (--m) {
        std::cin &gt;&gt; x;
        if (!std::cin || x &lt; 1 || x &gt; n) {
            std::cerr &lt;&lt; "Bad Input!\n";
            return EXIT_FAILURE;
        }
        auto [iter, created] = nums.insert(x);
        if (created)
            r += 2 * x;
        std::cout &lt;&lt; r &lt;&lt; '\n';
    }
}