#include #include #include using namespace std; int parseInt() { string line; getline(std::cin, line); size_t parsed; int const N = stoi(line, &parsed); if (parsed != line.size()) { cout << "Malformed integer input: " << line << endl; exit(1); } return N; } typedef unsigned long long NumberPart; /* 0~2^64-1 */ typedef unsigned char Digit; /* 0~255 */ void accumulate(vector &digits, NumberPart part) { // Add each digit from part to digits using division by 10 size_t di = 0; bool carry = 0; while (part or carry) { while (di >= digits.size()) { digits.push_back(0); } Digit const sum = digits[di] + (part % 10) + carry; carry = sum / 10; digits[di] = sum % 10; di++; part /= 10; } } int main(void) { int const N = parseInt(); vector digits; for (int i = 0; i < N; ++i) { NumberPart part; cin >> part; accumulate(digits, part); } for (int i = digits.size() - 1; i >= 0; --i) { cout << to_string(digits[i]); } cout << endl; return 0; }