Source Code
#include <iostream>
#include <string.h>
#include<vector>
#include<queue>
#include<stack>
#include<array>

using namespace std;

int sum1(long long int a) {
	int l = 0;
	while (a != 0) {
		l = l + a % 10;
		a = a / 10;
		
	}
	return l;
}




int main() {
	int n;
	cin >> n;
	int sum = 0;
	long long int test;
	for (int i = 1;i <= n;i++) {
		cin >> test;
		sum = sum + test;
		
	}
	while (sum > 10)
		sum = sum1(sum);
	cout << sum;
	
	return 0;
}
Copy
The Tale of a Generous Prince hoodlum awm
GNU G++17
2 ms
832 KB
Wrong Answer