Source Code
#include <iostream>
using namespace std;
int main()
{
	long long n, a[100000], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int x = 0;
		while (a[i] > 0) {
			x = a[i] % 10;
			a[i] /= 10;
		}
		a[i] = x;
	}
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}
	ans = 0;
	while (sum >0){
		ans += sum % 10;
		sum /= 10;

		
	}

	while (ans >= 10) {
		int y = ans;
		while (y > 0) {
			ans += y% 10;
			y /= y;
		}
	}

	cout << ans;
}
Copy
The Tale of a Generous Prince microwave6
GNU G++17
48 ms
1.6 MB
Wrong Answer