Chevonne's Necklace
题号:NC237063
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

For her excellent performance, pianist Chevonne was awarded a pearl necklace. The necklace consisted of n pearls which form a circle and are numbered clockwise.
To prevent the pearls from being covered with dust, she wants to move pearls from the necklace and wipe them. However, the way to remove the pearls is complex because of their uniqueness of them.
Specifically, every pearl on the necklace has a continuity value . Each turn, Chevonne can choose a pearl i with and move the pearl i and c_i - 1 clockwise consecutive pearls (c_i pearls in all). Be careful! If the number of remaining pearls is less than c_i, she will be unable to choose pearl i. After that, the remaining pearls will form a new circle.
Chevonne will repeat the process till she can't remove any pearls or all the pearls have been removed. She is curious about the maximum number of pearls she could remove and the number of such solutions.
Here, we use a set to describe a solution. The set contains the number i if Chevonne chose pearl i in some step. Two solutions are different if and only if the sets are different.

输入描述:

The first line of input contains one positive integer .
The following one line contains n non-negative integers separated by spaces. The i-th number represents . Pearls are numbered clockwise from 1 to n.

输出描述:

Please output two integers separated by one space.
The first one is the maximum number of pearls Chevonne could remove and the second one is the number of such solutions. Since the number of solutions may be very large, please output it modular 998244353.
示例1

输入

复制
6
0 1 1 3 3 1

输出

复制
6 3

说明

In the example, all the pearls could be removed by Chevonne, the 3 possible solutions are shown as follows:
1. Remove the 2, 3, 6, 4-th pearl in order.
2. Remove the 2, 3, 6, 5-th pearl in order.
3. Remove the 5, 4-th pearl in order.