Use a boolean flag to record if we have used the flip yet or not.

```
public int findMaxConsecutiveOnes(int[] nums) {
boolean flipused=false;
int res=0;
int tmp=0;
int half=0;
for(int a:nums){
if(a==1){
tmp++;
if(flipused) half++;
}else{
if(flipused){
res=Math.max(res, tmp);
tmp=half;
half=0;
tmp++;
}else{
flipused=true;
tmp++;
}
}
}
res=Math.max(res, tmp);
return res;
}
```