Source Code
#include <iostream>

using namespace std;

int main()
{
    int numOfIns, sum=0, tempsum=0;

    cin >> numOfIns;

    for (int i=0; i<numOfIns; i++){
        int v;
        cin >> v;
        sum += v;
    }

    while(sum/10 != 0){
        tempsum=0;
        while(sum/10 != 0){
            tempsum+=sum%10;
            sum/=10;
        }
        tempsum+=sum%10;
        sum = tempsum;
    }
    cout << sum;

    return 0;
}
Copy
The Tale of a Generous Prince Abd20200355
GNU G++17
3 ms
712 KB
Wrong Answer