#include <bits/stdc++.h>
using namespace std;

int main() {
	// longest common sequence
	// vector<int> arr={0,3,7,2,5,8,4,6,0,1};
	// unordered_map<int,bool> ok, check;
	// for(int i=0;i<arr.size();i++){
	// 	ok[arr[i]]=true;
	// }
	// int k=0;
	// for(int i=0;i<arr.size();i++){
	// 	if(ok.find(arr[i]-1)==ok.end() && ok[arr[i]]==true){
	// 	int t=arr[i];
	// 	int count=0;
	// 	while(ok[t]){
	// 			count++;
	// 			ok[t]=false;
	// 			t=t+1;
	// 	}
		
	// 	k=max(count,k);
	// 	}
	// }
	// cout<<k;
	
	
	//longest subarry with sum=0
	/* we will first calculate the prefix sum and find the max distance between the same element
	*/
	vector<int> arr={1,0,3};
	unordered_map<int,int> ok;
	int n=arr.size();
	vector<int> pre(n+1,0);
	for(int i=1;i<=n;i++){
		pre[i]=pre[i-1]+arr[i-1];
	}
	int count=0;
	for(int i=1;i<=n;i++){
		if(ok.find(pre[i])==ok.end()){
			ok[pre[i]]=i;
		}else{
			count=max(count,i-ok[pre[i]]);
		}
	}
	cout<<count;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}