#C2923. Candy Distribution Challenge

    ID: 46293 Type: Default 1000ms 256MiB

Candy Distribution Challenge

Candy Distribution Challenge

You have several bags of candies. In each bag, there are a certain number of candies. Your task is to form as many groups of three candies as possible by first taking the candies directly in groups of three from each bag, and then combining any leftover candies from all the bags. Any candies that are not enough to form a group of three after combining are left over.

Formally, you are given an integer \(n\) which represents the number of bags, and a list of \(n\) integers \(a_1, a_2, \dots, a_n\) where each \(a_i\) denotes the number of candies in the \(i\)-th bag. For each bag, you first form \(\lfloor a_i/3 \rfloor\) groups and note the remainder \(a_i \bmod 3\). Then, you sum up all the remainders to see if additional groups of three can be formed. The final answer consists of the total number of groups formed and the number of candies leftover that cannot form a complete group.

For example, if \(n = 4\) and the candies in each bag are [7, 11, 13, 9], you initially get groups: \(7 \to 2\), \(11 \to 3\), \(13 \to 4\), \(9 \to 3\) which sums to 12 groups and remainders: \(1, 2, 1, 0\) summing to 4. From these 4 candies, 1 additional group can be formed (4 divided by 3 gives 1 with remainder 1), so the final answer is 13 groups and 1 candy left over.

inputFormat

The first line contains an integer \(n\) representing the number of bags.

The second line contains \(n\) space-separated integers representing the number of candies in each bag.

outputFormat

Output two integers separated by a space: the maximum number of groups of three that can be formed and the number of leftover candies.

## sample
4
7 11 13 9
13 1