Source Code
#include <iostream>
using namespace std;

int main() {
	int inp,sum=0;
	cin>>inp;
	for(int i=0; i<inp; i++){
		int num;
		cin>>num;
		sum+=num;
	}
	int temp=sum;
	int n=0;
	while(temp!=0){
		int r=temp%10;
		temp/=10;
		n+=r;
	}
	int final=0;
	while(n!=0){
		int r=n%10;
		n/=10;
		final+=r;
	}
	cout<<final;
	return 0;
}
Copy
The Tale of a Generous Prince samihamad
GNU G++17
3 ms
768 KB
Wrong Answer