#P9858. Perfect square number

    ID: 8080 传统题 3000ms 512MiB 尝试: 11 已通过: 1 难度: 5 上传者: 标签>CF1700枚举前缀和数学2023“钉耙编程”中国大学生算法设计超级联赛(6)

Perfect square number

Perfect square number

Problem Description

You have an array of nn elements a1,a_1, a2,a_2, ...... , ana_n. You have an operation that can modify the value of a certain position to any of the values in [1,300][1,300]. (You can only perform it once) Find the maximum number of intervals that satisfy the interval sum is a Perfect square number.

Input

The description of the test cases follows. The first line contains one integer nn1 n3001\le \ n \le 300). The second line contains nn integers a1, a2, ..., ana_1, \ a_2, \ ..., \ a_n1ai3001\le a_i \le 300).

Output

For each test case, output the maximum number.

Sample Input

3
1 1 1

Sample Output

4

Hint

For the first query, change a2=3a_2=3. For the second query, change a2=1a_2=1.

Source

2023“钉耙编程”中国大学生算法设计超级联赛(6)