#include <array>
#include <cstddef>
#include <iostream>
#include <limits>

bool add_checked(unsigned value, unsigned& total) {
    const unsigned M{std::numeric_limits<unsigned>::max()};
    if (value > M - total) {
        return false;
    }
    total += value;
    return true;
}

int main() {
    std::array<unsigned, 3> values{2u, 4u, 6u};
    unsigned total{0};
    bool accepted{true};
    for (std::size_t i{0}; i < values.size(); ++i) {
        if (!add_checked(values[i], total)) {
            accepted = false;
            break;
        }
    }
    std::cout << accepted << ' ' << total << '\n';

    std::array<unsigned, 0> empty{};
    total = 0;
    accepted = true;
    for (std::size_t i{0}; i < empty.size(); ++i) {
        if (!add_checked(empty[i], total)) {
            accepted = false;
            break;
        }
    }
    std::cout << accepted << ' ' << total << '\n';

    const unsigned M{std::numeric_limits<unsigned>::max()};
    std::array<unsigned, 2> overflow{M, 1u};
    total = 0;
    accepted = true;
    for (std::size_t i{0}; i < overflow.size(); ++i) {
        if (!add_checked(overflow[i], total)) {
            accepted = false;
            break;
        }
    }
    std::cout << accepted << ' ' << (total == M) << '\n';
    return 0;
}
