#include <iostream>
#include <span>
#include <vector>

// At most 100 values in [-100, 100]; every partial sum fits in int.
int total(std::span<const int> values) {
    int result{0};
    for (const auto& value : values) {
        result += value;
    }
    return result;
}

int main() {
    const std::vector<int> original{3, 1, 4, 1, 5};
    const std::span<const int> borrowed{original};
    std::vector<int> copy{original};
    copy[0] += 10;
    const std::span<const int> copied_view{copy};
    const std::span<const int> empty{};
    std::cout << total(borrowed) << '\n';
    std::cout << total(copied_view) << '\n';
    std::cout << total(borrowed) << '\n';
    std::cout << total(empty) << '\n';
    return 0;
}
