Source Code
#include <iostream>
using namespace std;

int main() {
	
	long long n;
	cin>>n;
	unsigned long long bigsum=0;
	for(int i=0; i<n; i++){
		unsigned long long input;
		cin>>input;
		bigsum+=input;
	}
	while(bigsum>9){
	unsigned long long summation=0;
	unsigned long long finalsum=bigsum;
		while(finalsum!=0){
			summation+=finalsum%10;
			finalsum/=10;
		}
		bigsum=summation;
	}
	cout<<bigsum;
	
	
	return 0;
}
Copy
The Tale of a Generous Prince samihamad
GNU G++17
55 ms
1.0 MB
Wrong Answer