Problem list
Log in
#r03214 · Online Judge > GoldOJ

Subsequences Summing to Sevens

Gold V 2.0 s 256 MB

Given $N$ cow IDs in a line, find the longest contiguous group whose ID sum is a multiple of $7$, and print its length (number of cows). If no such group exists, print $0$.

Input

Line 1: $N$ ($1 \le N \le 50000$). Next $N$ lines: an ID each ($0 \le \text{ID} \le 10^6$).

Output

Print the length of the longest valid contiguous group.

Example 1

Input
7
3
5
1
6
2
14
10
Output
5
Source
Online Judge > GoldOJ
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code