Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	max, cnt := 0, 0
	for i := 0; i < N; i++ {
		cnt++
		if nextInt() == 0 {
			cnt = 0
		}
		if cnt > max {
			max = cnt
		}
	}
	fmt.Println(max + 1)
}

C++: #include<iostream>
using namespace std;
int main(){
  int N,A[10000],count=0,save=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]==1){
      count++;
      if(i==N-1){
        if(save<count){
          save=count;
          count=0;
        }
      }
      
    }
    else if(A[i]==0){
      if(save<count){
        save=count;
        count=0;
      }else
        count=0;
    }
  }
  cout<<save+1<<endl; 
}