Source Code
#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	long long int* arr = new long long int[n];

	int count = 0;

	for (int i = 0; i < n;i++)
		cin >> arr[i];

	for (int i = 0;i < n;i++) {
		count += arr[i];
	}

	while (count > 9) {
		int sum = 0;
		while (count != 0)
		{
			sum += count % 10;
			count /= 10;
		}
		count = sum;
	}

	cout << count;

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