use std::io::stdin;

fn main() {
    let mut a = String::new();
    let mut b = String::new();
    stdin().read_line(&mut a).unwrap();
    stdin().read_line(&mut b).unwrap();
    let a: Vec<char> = a.trim().chars().collect();
    let b: Vec<char> = b.trim().chars().collect();

    let mut answer = String::new();

    for i in 0..a.len() {
        if a[i] != b[i] {
            answer.push_str("1");
        } else {
            answer.push_str("0");
        }
    }

    println!("{}", answer);
}

#[allow(unused)] use std::io::*;
#[allow(unused)] use std::collections::*;
#[allow(unused)] use std::mem::*;
#[allow(unused)] use std::num::*;
#[allow(unused)] use std::cmp::*;
#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{
    let mut inp = String::new(); stdin().read_line(&mut inp).ok();
    let s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).collect();
    let mut cnt : usize = 0;
    fn next<T>(cnt: &mut usize, p: &Vec<&str>) -> T where T:std::str::FromStr
    { *cnt += 1; p[*cnt-1].parse().ok().unwrap() }
    ($(next::<$x>(&mut cnt, &s)), +)
    }}; }
#[allow(unused)] macro_rules! arr { ($($n:expr, $T:ty), +) => {{
    let mut inp = String::new(); stdin().read_line(&mut inp).ok();
    let mut s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0);
    ($({let mut v = Vec::new(); v.reserve(($n) as usize);
        for _ in 0..$n { let t = s.next(); if t == None { break; }
        v.push(t.unwrap().parse::<$T>().unwrap()); } v }),+)
    }}; }

///////////////////////////////////////////////////////////////////////////////
fn main()
{
    scan!(String).chars().zip(scan!(String).chars()).map(|(x, y)| if x == y { 0 } else { 1 }).for_each(|x| print!("{}", x));
}

fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let a = input();
    let b = input();
    let res = a
        .chars()
        .zip(b.chars())
        .map(|(a, b)| if a == b { '0' } else { '1' })
        .collect::<String>();
    println!("{}", res)
}

//spnauti-rust
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader { it : s
            .split_ascii_whitespace()
            .map(String::from).collect::<Vec<_>>()
            .into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    input.ab().into_iter().zip(input.ab().into_iter()).for_each(|(a,b)| {
        print!("{}", if a != b {1} else {0})
    });
}

fn main() {
    let a = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().to_string()
    };
    let b = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().to_string()
    };

    let ret: String = a.chars()
        .zip(b.chars())
        .map(|(x, y)| if x == y { '0' } else { '1' })
        .collect();
    println!("{}", ret);
}

use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut iterator = stdin.lock().lines();
    let first = iterator.next().unwrap().unwrap();
    let second = iterator.next().unwrap().unwrap();

    let first_vec: Vec<char> = first.chars().collect();
    let second_vec: Vec<char> = second.chars().collect();

    let mut result = Vec::new();

    for i in 0..first_vec.len() {
        if first_vec[i] != second_vec[i] {
            result.push("1");
        } else {
            result.push("0");
        }
    }

    println!("{}", result.join(""));
}

use std::io::stdin;

fn main() {
    let mut a = String::new();
    let mut b = String::new();
    stdin().read_line(&mut a).unwrap();
    stdin().read_line(&mut b).unwrap();
    let a: Vec<char> = a.trim().chars().collect();
    let b: Vec<char> = b.trim().chars().collect();

    let mut answer = String::new();

    for i in 0..a.len() {
        if a[i] != b[i] {
            answer.push_str("1");
        } else {
            answer.push_str("0");
        }
    }

    println!("{}", answer); //Hola
}

use std::io;

fn read_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let l1 = read_line();
    let l2 = read_line();
    let ans = l1.chars().zip(l2.chars()).map(|(c1, c2)| if c1 == c2 { '0' } else { '1' }).collect::<String>();
    println!("{}", ans);
}

use std::io::*;

fn read<T: std::str::FromStr>(i: &mut StdinLock) -> T {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn bits(i: impl Iterator<Item = char>) -> impl Iterator<Item = bool> {
    i.map(|x| x == '0')
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let input1: String = read(sin);
    let input2: String = read(sin);

    let ans: String = bits(input1.as_str().chars())
        .zip(bits(input2.as_str().chars()))
        .map(|x| x.0 ^ x.1)
        .map(|x| if x { '1' } else { '0' })
        .collect();

    println!("{}", ans);
}

// https://codeforces.com/problemset/problem/61/A
use std::io;

fn main() {
    let mut a = String::new();

    io::stdin()
        .read_line(&mut a)
        .unwrap();

    let a = a.trim();

    let a: Vec<char> = a.chars().collect();

    let mut b = String::new();

    io::stdin()
        .read_line(&mut b)
        .unwrap();

    let b = b.trim();

    let b: Vec<char> = b.chars().collect();

    let mut answer = String::from("");

    for i in 0..a.len() {
        if a[i] == b[i] {
            answer.push_str("0");
        } else {
            answer.push_str("1");
        }
    }
    println!("{}", answer);
}

// https://codeforces.com/problemset/problem/61/A
// implementation, simulation
use std::io;

fn main() {
    let mut a = String::new();

    io::stdin()
        .read_line(&mut a)
        .unwrap();

    let a = a.trim();

    let mut b = String::new();

    io::stdin()
        .read_line(&mut b)
        .unwrap();

    let b = b.trim();

    let mut iter = b.chars();

    let mut answer = String::from("");

    for ch in a.chars() {
        if ch == iter.next().unwrap() {
            answer.push_str("0");
        } else {
            answer.push_str("1");
        }
    }

    println!("{}", answer);
}

use std::io::{self, Read};

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer
}

fn main() -> io::Result<()> {
    let input1 = get_input().trim().to_string();
    let input2 = get_input().trim().to_string();

    for i in 0..input1.len() {
        let c1 = input1.chars().nth(i);
        let c2 = input2.chars().nth(i);
        if c1 == c2 {
            print!("{}", 0);
        } else {
            print!("{}", 1);
        }
    }
    print!("\n");

    Ok(())
}

use std::io::{self, prelude::*};

#[allow(unused_must_use)]
fn solve<B: BufRead, W: Write>(mut scan: Scanner<B>, mut w: W) {
    let a: Vec<char> = scan.token::<String>().chars().collect();
    let b: Vec<char> = scan.token::<String>().chars().collect();

    let mut c: Vec<char> = Vec::new();

    for (i, _) in a.iter().enumerate() {
        if a[i] == b[i] {
            c.push('0');
        } else {
            c.push('1');
        }
    }

    let ans: String = c.into_iter().collect();

    writeln!(w, "{}", ans);
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    solve(reader, writer);
}

#[allow(dead_code)]
fn matrix_to_str<T: ToString>(matrix: &Vec<Vec<T>>, separator: &str) -> String {
    use std::fmt::Write;
    let mut ans = String::new();
    for line in matrix.iter() {
        for elem in line.iter() {
            write!(&mut ans, "{}{}", elem.to_string(), separator).unwrap();
        }
        write!(&mut ans, "\n").unwrap();
    }
    ans
}
pub struct Scanner<B> {
    reader: B,
    buf_str: Vec<u8>,
    buf_iter: std::str::SplitWhitespace<'static>,
}
impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_whitespace()
        }
    }
    pub fn token<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
            self.buf_iter = unsafe {
                let slice = std::str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace()) }
        }
    }
    pub fn get_matrix<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>> {
        // m rows and n columns
        let mut ans: Vec<Vec<T>> = Vec::with_capacity(m);
        for i in 0..m {
            ans.push(Vec::with_capacity(n));
            for _ in 0..n {
                ans[i].push(self.token::<T>());
            }
        }
        ans
    }
}

use std::io;

fn main() {
    let mut s = vec![String::new(), String::new()];
    for i in 0..2 {
        io::stdin().read_line(&mut s[i as usize]).unwrap();
        s[i as usize] = s[i as usize].trim().to_string();
    }
    for i in 0..s[0].len() {
        if s[0].chars().nth(i) != s[1].chars().nth(i) {
            print!("1");
        } else {
            print!("0");
        }
    }
}

#![allow(unused_imports)]
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::str::FromStr;

fn main() {
    let mut first = String::new();
    let mut second = String::new();
    io::stdin().read_line(&mut first).unwrap();
    io::stdin().read_line(&mut second).unwrap();
    let fir: Vec<char> = first.chars().filter(|c| c.is_digit(2)).collect();
    let sec: Vec<char> = second.chars().filter(|c| c.is_digit(2)).collect();
    let mut out = vec!['_'; fir.len()];

    for i in 0..fir.len() {
        if fir[i] == sec[i] {
            out[i] = '0';
        } else {
            out[i] = '1';
        }
    }

    println!("{}", out.iter().collect::<String>());
}

use std::str::FromStr;
use std::fmt::Debug;

fn main() {
    let num_1 = read_line().to_vec_chars();
    let num_2 = read_line().to_vec_chars();
    let mut s = String::with_capacity(num_1.len());

    for i in 0..num_1.len() {
        if num_1[i] == num_2[i] {
            s.push('0')
        } else {
            s.push('1')
        }
    }
    println!("{}", s);
}

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Ошибка чтения");

    buffer.trim().to_string()
}

trait ParseStr {
    fn to_vec<T>(&self, separator: &str) -> Vec<T>
    where
        T: FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug;

    fn to_vec_chars(&self) -> Vec<char>;

    fn to<T>(&self) -> T
    where
        T: FromStr + Copy,
        <T as std::str::FromStr>::Err: Debug;
}

impl ParseStr for String {

    fn to_vec<T>(&self, separator: &str) -> Vec<T>
    where
        T: FromStr,
        <T as std::str::FromStr>::Err: Debug,
    {
        self.split(separator).map(|c| c.parse::<T>().expect("Ошибка преобразования")).collect()
    }

    fn to_vec_chars(&self) -> Vec<char> {
        self.chars().collect()
    }

    fn to<T>(&self) -> T
    where
        T: FromStr + Copy,
        <T as std::str::FromStr>::Err: Debug,
    {
        ParseStr::to_vec::<T>(self, " ")[0]
    }
}

fn read_str() -> String {
    let mut buffer: String = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Error");
    buffer.trim().to_string()
}

fn main() {
    let (length, a): (usize, u128) = {
        let s: String = read_str();
        (s.len(), u128::from_str_radix(&s[..], 2).expect("Error"))
    };
    let b: u128 = {
        let s: String = read_str();
        u128::from_str_radix(&s[..], 2).expect("Error")
    };

    print!("{:01$b}", a ^ b, length);
}

use std::io;
use std::io::Stdin;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn print_result(s_1 : &String, s_2 : &String) {
    let pair_iter = s_1.trim().chars().zip(s_2.trim().chars());
    for (a, b) in pair_iter {
        if a == b {
            print!("0");
        } else {
            print!("1");
        }
    }
    println!();
}

fn main() {
    let stdin = io::stdin();
    let mut s_1 = String::new();
    let mut s_2 = String::new();
    read_line(&stdin, &mut s_1);
    read_line(&stdin, &mut s_2);
    print_result(&s_1, &s_2);
}

fn main() {
    let s: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };
    let t: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let n = s.len();
    let mut ans = String::new();

    for i in 0..n {
        ans.push(if s.get(i) != t.get(i) { '1' } else { '0' });
    }

    println!("{}", ans);
}

fn main() {
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).unwrap();
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).unwrap();

    for i in 0..a.trim().len() {
        if a.as_bytes()[i] != b.as_bytes()[i] {
            print!("1");
        }
        else {
            print!("0");
        }
    }
}

use std::io;

fn main() {
	let mut string1 = String::new();
	io::stdin().read_line(&mut string1).unwrap();
	let string1 = string1.trim();

	let mut string2 = String::new();
	io::stdin().read_line(&mut string2).unwrap();
	let string2 = string2.trim();

	for i in 0..string1.len() {
		if string1.chars().nth(i) != string2.chars().nth(i) {
			print!("1");
		} else {
			print!("0");
		}
	}
	println!();
}

use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut input1 = String::new();
    let mut input2 = String::new();

    stdin.lock().read_line(&mut input1).unwrap();
    stdin.lock().read_line(&mut input2).unwrap();

    for (i, j) in input1.trim().chars().zip(input2.trim().chars()) {
        if i == j {
            print!("0");
        } else {
            print!("1");
        }
    }
    println!();
}

use std::io;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn main() {
    let s = read_line();
    let t = read_line();

    for (ps, pt) in s.chars().zip(t.chars()) {
        if ps == pt {
            print!("0");
        } else {
            print!("1");
        }

    }

}

#[allow(unused_imports)]
use std::cmp::{min,max};
use std::io::{BufWriter, stdin, stdout, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

	let a = scan.next::<String>();
	let b = scan.next::<String>();
    let ab = a.as_bytes();
    let bb = b.as_bytes();

    for i in 0..ab.len() {
        write!(out, "{}", ab[i] ^ bb[i]).expect("fail");
    }

    writeln!(out, "").expect("fail");
}

fn main() {
    let a = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().to_string()
    };
    let b = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().to_string()
    };
    let x = i32::from_str_radix(&a, 2).unwrap();
    let y = i32::from_str_radix(&b, 2).unwrap();
    let z = x ^ y;

    println!("{}", format!("{:b}", z));
}

use std::io::stdin;

fn main() {
    let mut a = String::new();
    let mut b = String::new();
    stdin().read_line(&mut a).unwrap();
    stdin().read_line(&mut b).unwrap();
    let a: Vec<char> = a.chars().collect();
    let b: Vec<char> = b.chars().collect();

    let mut answer = String::new();

    for i in 0..a.len() {
        if a[i] != b[i] {
            answer.push_str("1");
        } else {
            answer.push_str("0");
        }
    }

    println!("{}", answer);
}

use std::io;

fn main() {
	let mut string1 = String::new();
	io::stdin().read_line(&mut string1).unwrap();

	let mut string2 = String::new();
	io::stdin().read_line(&mut string2).unwrap();

	for i in 0..(string1.len()-1) {
		if string1.chars().nth(i) == string2.chars().nth(i) {
			print!("0");
		} else {
			print!("1");
		}
	}

}

use std::io;

fn main() {
	let mut string1 = String::new();
	io::stdin().read_line(&mut string1).unwrap();

	let mut string2 = String::new();
	io::stdin().read_line(&mut string2).unwrap();

	for i in 0..(string1.len()-1) {
		if string1.chars().nth(i) == string2.chars().nth(i) {
			print!("0");
		} else {
			print!("1");
		}
	}
	println!();
}

use std::io;

fn main() {
	let mut string1 = String::new();
	io::stdin().read_line(&mut string1).unwrap();

	let mut string2 = String::new();
	io::stdin().read_line(&mut string2).unwrap();

	for i in 0..string1.len()-1 {
		if string1.chars().nth(i) == string2.chars().nth(i) {
			print!("0");
		} else {
			print!("1");
		}
	}
	println!();
}

use std::io;

fn main() {
	let mut string1 = String::new();
	io::stdin().read_line(&mut string1).unwrap();

	let mut string2 = String::new();
	io::stdin().read_line(&mut string2).unwrap();

	for i in 0..string1.len()-1 {
		if string1.chars().nth(i) != string2.chars().nth(i) {
			print!("1");
		} else {
			print!("0");
		}
	}
	println!();
}


use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    for _ in 0..n + 1 {
        let _: String = sc.ne();
    }
    println!("{}",
             match n & 1 {
                 1 => "contest",
                 _ => "home",
             });
}

fn main() {
    const DEFAULT_STACK: usize = 16 * 1024 * 1024;
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => panic!("parse error"),
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}

use std::collections::HashMap;
use std::io::{self};
use std::str::FromStr;
use std::process;

fn main() {
    let mut buffer = String::new();
    let mut nbuff = String::new();
    let mut flights: HashMap<&str, i8> = HashMap::new();
    let stdin = io::stdin();

    stdin.read_line(&mut buffer).expect("Cannot_read_data1!!!");
    stdin.read_line(&mut buffer).expect("Cannot_read_dat2!!!");
    let lines: Vec<&str> = buffer.trim().split("\n").collect();

    let n: i8 = FromStr::from_str(lines[0].trim()).unwrap();

    let home = lines[1];
    let mut home_vec: Vec<&str> = vec![];

    for _ in 0..n {
        stdin.read_line(&mut nbuff).expect("Cannot_read_dat3!!!");
    }

    let nlines: Vec<&str> = nbuff.trim().split("\n").collect();

    for x in &nlines {
        let points: Vec<&str> = x.trim().split("->").collect();

        if *points[0] == *home {
            home_vec.push(points[1]);
        } else {
            if flights.contains_key(points[0]) {
                if let Some(y) = flights.get_mut(points[0]) {
                    *y += 1;
                }
            } else {
                flights.insert(points[0], 1);
            }
        }
    }

    let mut result = "home";

    for x in &home_vec {
        if !flights.contains_key(x) {
            result = "contest";
            break;
        } else {
            if let Some(y) = flights.get_mut(x) {
                if *y == 0 {
                    result = "contest";
                    break;
                }
                *y -= 1;
            }
        }
    }

    println!("{}", result);
    process::exit(0);

}


//spnauti-rusT
use std::io::*;
use std::str::{self,*};
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_macros)]
macro_rules! m {
    ($c:tt, $x:expr, $y:expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
#[allow(unused_macros)]
macro_rules! l {
    ($($v:ident),* = $i:ident.$f:ident $a:tt) => {
        $( let $v = $i.$f$a; )*
    };
    ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {
        $( let $v:$t = $i.$f$a; )*
    };
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a> }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).ok();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn f(&mut self) ->    f64 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn sk(&mut self, n: usize) { self.it.nth(n - 1); }
    fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> {
        self.ip(n).into_iter()
    }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}
//------------------- End rusT

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    let n = input.i();
    let sol = if n % 2 == 1 {
        0
    } else {
        (n - 2) / 4
    };
    println!("{}", sol);
}

#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_macros)]

use std::char::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

const MAX:usize = 100006;
const MOD:i64 = 1e9 as i64 + 7;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

use std::hash::Hash;
fn inc<T: Hash+Ord>(map:&mut BTreeMap<T,i64>, key:T) {
    let count = map.entry(key).or_insert(0);
    *count += 1;
}

fn mod_pow(x:i64, n:i64, m:i64) -> i64 {
    let mut x = x;
    let mut n = n;
    let mut res = 1i64;
    while n > 0 {
        if n & 1 > 0 {
            res = res * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    res
}

fn main() {
    input!{n:i64};
    if n%2 != 0 {
        println!("0");
        return();
    }
    println!("{}", (n/2-1)/2);
}

use std::io;

macro_rules! parse_line {
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        io::stdin().read_line(&mut a_str).unwrap();
        let mut a_iter = a_str.split_whitespace();
        (
            $(
            a_iter.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    })
}

fn main() {
    let (mut n,) = parse_line!(u32);
    if n % 2 != 0 {
        println!("{}", 0);
        return;
    }
    n /= 2;
    println!("{}", n / 2 - ((n % 2) ^ 1));
}


#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(overflowing_literals)]
#![allow(unused_must_use)]

use std::collections::*;
use std::io::*;
use std::cmp::{min, max};
use std::f64::consts::*;
use std::mem::swap;
use std::fs::File;
use std::rc::*;
use std::ascii::*;
use std::ops::*;

const INF: i32 = std::i32::MAX;
const LINF: i64 = std::i64::MAX;
const MOD: i32 = 1000000007;

#[derive(PartialEq, PartialOrd, Eq, Ord, Copy, Clone)]
struct Pair<A: Eq + Ord + Clone, B: Eq + Ord + Clone>(A, B);

struct Input<Buf: BufRead>
{
	buffer: Buf
}

impl<Buf: BufRead> Input<Buf>
{
	fn read_line(&mut self) -> String {
		let mut v = Vec::new();
		let mut x = [255u8];
		self.buffer.read(&mut x).expect("EOF");
		while x[0] < b' ' && x[0] != 255u8 {
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		while x[0] >= b' ' && x[0] != 255u8 {
			v.push(x[0]);
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		String::from_utf8(v).unwrap()
	}

	fn read_word(&mut self) -> String {
		let mut v = Vec::new();
		let mut x = [255u8];
		self.buffer.read(&mut x).expect("EOF");
		while x[0] <= b' ' && x[0] != 255u8 {
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		while x[0] > b' ' && x[0] != 255u8 {
			v.push(x[0]);
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		String::from_utf8(v).unwrap()
	}
	#[inline]
	fn read_int(&mut self) -> i32 {
		self.read_word().parse::<i32>().expect("Parsing error")
	}
	#[inline]
	fn read_long(&mut self) -> i64 {
		self.read_word().parse::<i64>().expect("Parsing error")
	}
	#[inline]
	fn read_usize(&mut self) -> usize {
		self.read_word().parse::<usize>().expect("Parsing error")
	}
	#[inline]
	fn read_double(&mut self) -> f64 {
		self.read_word().parse::<f64>().expect("Parsing error")
	}
}
macro_rules! read {
    () => {};
	($inf:ident,$($t:ty),*) => ({($({$inf.read_word().parse::<$t>().expect("Parsing error")}),*)});
}
fn gcd<T: RemAssign + Ord + From<i32> + Copy>(x: T, y: T) -> T {
	let (mut a, mut b) = (x, y);
	while b > T::from(0) {
		a %= b;
		swap(&mut a, &mut b);
	}
	a
}

fn main() {
	match std::env::var("home") {
		Ok(_x) => {
			let mut inf = Input {
				buffer: BufReader::new(File::open("input.txt").expect("File not found"))
			};
			let mut ouf = BufWriter::new(stdout());
			solve(&mut inf, &mut ouf);
		}
		Err(_e) => {
			let mut inf = Input { buffer: BufReader::new(stdin()) };
			let mut ouf = BufWriter::new(stdout());
			solve(&mut inf, &mut ouf);
		}
	}
}

fn solve<Inner: BufRead, Output: Write>(inf: &mut Input<Inner>, ouf: &mut Output)
{
	let n = read!(inf,i32);
	let mut s = (n as f64).sqrt() as i32;
	if s * s < n {
		s += 1;
	}

	writeln!(ouf, "{}", 2 * (s + ((n + s - 1) / s)));
}

fn main() {
    let mut sc = new(std::io::stdin());
    let n: usize = sc.next();
    let mut res = 1_000_000_000;
    for h in 1..(n + 1) {
        let w = (n + h - 1) / h;

        if (h + w) * 2 < res {
            res = (h + w) * 2;
        }
    }
    println!("{}", res);
}

use std::io;
use std::io::BufRead;

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

pub fn new<R: io::Read>(r: R) -> Scanner<R> {
    Scanner::new(r)
}

impl<R: io::Read> Scanner<R> {
    #[inline]
    fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: ")).unwrap()
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}

#![allow(unused_imports)]
#![allow(unused_macros)]
use std::io::{StdinLock, stdin, BufRead};
use std::collections::*;
use std::cmp::*;

fn scan_helper(lock : &mut StdinLock) -> String {
    let mut buffer = String::new();
    lock.read_line(&mut buffer).ok();
    buffer
}

macro_rules! scan {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .next().unwrap()
            .parse::<$t>().unwrap()
    });
    ($lock:ident, $($t:ty),+) => ({
        let buffer = scan_helper(&mut $lock);
        let mut iter = buffer.split_whitespace();
        ($(
            {
                iter.next().unwrap()
                    .parse::<$t>().unwrap()
            },
        )+)
    })
}

macro_rules! scan_iter {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect()
    })
}

trait Ext {
    fn idx(&self) -> usize;
    fn num(&self) -> i64;
}

macro_rules! ext {
    ($t:ty) => (
        impl Ext for $t {
            #[inline]
            fn idx(&self) -> usize {
                *self as usize
            }

            #[inline]
            fn num(&self) -> i64 {
                *self as i64
            }
        }
    )
}
ext!(i64);
ext!(usize);

macro_rules! derive_regular {
    ($t:ty) => (
        impl Ord for $t {
            fn cmp(&self, other : &$t) -> Ordering {
                self.partial_cmp(other).unwrap()
            }
        }
        impl PartialEq for $t {
            fn eq(&self, other : &$t) -> bool {
                self.cmp(other) == Ordering::Equal
            }
        }
        impl Eq for $t {}
    )
}

fn main() {
    let stdin = stdin();
    let mut s = stdin.lock();
    let n = scan!(s, usize);
    let max_n = 1000000;
    let mut squares = vec![2*max_n; 2001];
    squares[0] = 0;

    let mut i = 1;
    while i*i <= max_n {
        squares[i] = i*i;
        i += 1;
    }

    while squares[i] > n {
        i -= 1;
    }

    let mut result = 4*i;
    let diff = n - squares[i];
    if diff > 0 {
        if diff > i {
            result += 4;
        } else {
            result += 2;
        }
    }

    println!("{}", result);
}


#![allow(non_snake_case, unused_imports, deprecated, dead_code)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{VecDeque,HashSet,HashMap,BinaryHeap};
// Module for v1.15.1
use std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead

// Functions

// Main
fn main() {

    input! {
        N: usize,
        A: [i64; N]
    }

    let mut ans = 0;

    for i in 0..N {
        for j in i..N{
            let mut cnt = 0;
            for x in 0..N{
                if (x < i || j < x) && A[x]==1 {
                    cnt += 1;
                } else if i <= x && x <= j && A[x]==0 {
                    cnt += 1;
                }
            }
            ans = max(ans,cnt);
        }
    }

    println!("{}", ans);
}

use std::io::{stdin, BufRead};

fn get_max_delta<T>(values: &Vec<T>) -> Option<(T, usize, usize)>
where
    T: Ord,
    T: Copy,
    T: std::ops::Sub<Output = T>,
{
    if values.len() <= 1 {
        return None;
    }

    let mut min_positions: Vec<usize> = Vec::new();
    let mut max_positions: Vec<usize> = Vec::new();

    min_positions.push(0);
    max_positions.push(1);

    for i in 1..(values.len() - 1) {
        let value = values[i];
        let prev_value = values[i - 1];
        let next_value = values[i + 1];

        if (value >= prev_value) && (value >= next_value) {
            max_positions.push(i);
        }
        if (value <= prev_value) && (value <= next_value) {
            min_positions.push(i);
        }
    }

    min_positions.push(values.len() - 1);
    if values.len() > 2 {
        max_positions.push(values.len() - 1);
    }

    let mut max_delta: Option<(T, usize, usize)> = None;
    let mut max_position_index: usize = 0;

    for i in 0..min_positions.len() {
        let min_position = min_positions[i];
        let min_position_value = values[min_position];
        while max_positions[max_position_index] <= min_positions[i] {
            max_position_index += 1;
            if max_position_index >= max_positions.len() {
                break;
            }
        }
        if max_position_index >= max_positions.len() {
            break;
        }
        for j in max_position_index..max_positions.len() {
            let max_position = max_positions[j];
            let max_position_value = values[max_position];
            let delta_value = max_position_value - min_position_value;
            if let Some((max_delta_value, _max_delta_start, _max_delta_end)) = max_delta {
                if delta_value > max_delta_value {
                    max_delta = Some((delta_value, min_position, max_position));
                }
            } else {
                max_delta = Some((delta_value, min_position, max_position));
            }
        }
    }

    return max_delta;
}

fn get_best_score(values: &Vec<u8>) -> usize {
    let mut switch_scores: Vec<isize> = Vec::with_capacity(values.len() + 1);
    switch_scores.push(0);
    let mut current_switch_score: isize = 0;
    let mut base_score: usize = 0;
    for &value in values {
        if value == 0 {
            current_switch_score += 1;
        } else {
            current_switch_score -= 1;
            base_score += 1;
        }
        switch_scores.push(current_switch_score);
    }

    let (max_switch_score, _, _) = get_max_delta(&switch_scores).unwrap();

    return ((base_score as isize) + max_switch_score) as usize;
}

#[cfg(test)]
mod tests {
    use super::{get_best_score, get_max_delta};

    #[test]
    fn test_get_best_score_1() {
        assert_eq!(get_best_score(&vec![1, 0, 0, 1, 0]), 4);
    }
    #[test]
    fn test_get_best_score_2() {
        assert_eq!(get_best_score(&vec![1, 0, 0, 1]), 4);
    }
    #[test]
    fn test_get_best_score_3() {
        assert_eq!(get_best_score(&vec![1, 0, 1, 0, 1, 0]), 4);
    }
    #[test]
    fn test_get_best_score_4() {
        assert_eq!(get_best_score(&vec![1]), 0);
    }
    #[test]
    fn test_get_best_score_5() {
        assert_eq!(get_best_score(&vec![0]), 1);
    }

    fn do_test_max_delta(values: &Vec<i32>) {
        if values.len() <= 1 {
            assert_eq!(get_max_delta(values), None);
            return;
        }

        let mut max_delta: Option<i32> = None;
        for i in 0..values.len() {
            for j in (i + 1)..values.len() {
                let delta: i32 = values[j] - values[i];
                if let Some(max_delta_value) = max_delta {
                    if delta > max_delta_value {
                        max_delta = Some(delta);
                    }
                } else {
                    max_delta = Some(delta);
                }
            }
        }

        let (result_max_delta, result_start, result_end) = get_max_delta(values).unwrap();
        assert_eq!(result_max_delta, max_delta.unwrap());
        assert_eq!(
            values[result_end] - values[result_start],
            max_delta.unwrap()
        );
    }

    #[test]
    fn test_get_max_delta_1() {
        do_test_max_delta(&vec![1, 2, 7, 19, 20, 3, 0, -4, 4]);
    }
    #[test]
    fn test_get_max_delta_2() {
        do_test_max_delta(&vec![0, 0, 0, 3]);
    }
    #[test]
    fn test_get_max_delta_3() {
        do_test_max_delta(&vec![1]);
    }
    #[test]
    fn test_get_max_delta_4() {
        do_test_max_delta(&vec![0, -1, -2, -3]);
    }
}

fn main() {
    let stdin = stdin();
    let mut stdin_lock = stdin.lock();

    {
        let mut skip_buffer = String::new();
        stdin_lock.read_line(&mut skip_buffer).unwrap();
    }
    let mut string_buffer = String::new();
    stdin_lock.read_line(&mut string_buffer).unwrap();
    let values: Vec<u8> = string_buffer
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<u8>().unwrap())
        .collect();

    let best_score: usize = get_best_score(&values);
    println!("{}", best_score);
}

//spnauti-rust
#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader {
            it : s.split_ascii_whitespace().map(String::from)
            .collect::<Vec<_>>().into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let n = input.i();
    let mut sum = 0;
    let mut max = 0;
    let mut sol = -1;
    for _ in 0..n {
        sum += input.i() * 2 - 1;
        a!(>,sol,max-sum);
        a!(>,max,sum);
    }
    let sum = (sum + n) / 2;
    let sol = sol + sum;
    println!("{}", sol);
}

// 2018-10-12 13:59
fn main() {
    let _ = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim()
            .split(" ")
            .map(|s| s.parse::<i32>().unwrap())
            .collect()
    };

    let n = v.len();
    let orig = v.iter().filter(|&x| *x == 1).count() as i32;

    let mut dp = vec![vec![0; n + 1]; n + 1];
    let mut inc = -1;
    for i in 0..n {
        for j in i + 1..n + 1 {
            dp[i][j] = {
                if v[j - 1] == 0 {
                    dp[i][j - 1] + 1
                } else {
                    dp[i][j - 1]
                }
            };
            inc = std::cmp::max(inc, dp[i][j] * 2 - (j - i) as i32);
        }
    }
    println!("{:?}", inc + orig);
}

// 2018-10-12 13:59
fn main() {
    let _ = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim()
            .split(" ")
            .map(|s| s.parse::<i32>().unwrap())
            .collect()
    };

    let n = v.len();
    let orig = v.iter().filter(|&x| *x == 1).count() as i32;

    let mut inc = -1;

    for i in 0..n {
        let mut prev = 0;
        for j in i + 1..n + 1 {
            if v[j - 1] == 0 {
                prev += 1
            }
            inc = std::cmp::max(inc, prev * 2 - (j - i) as i32);
        }
    }
    println!("{:?}", inc + orig);
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n : usize = s.trim().parse().unwrap();
    s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let ints:Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut max = 0;
    let mut onesum = vec![];
    let mut onerevsum = vec![];
    let mut sum = 0;
    let mut revsum = 0;

    for i in 0..n {
        onesum.push(sum);
        onerevsum.insert(0,revsum);
        sum+=ints[i];
        revsum+=ints[n-i-1];
    }

    for i in 0..n {
        for j in i..n {
            max = std::cmp::max(max, ints[i..=j].iter().fold(0, |acc, x| acc+(1-x)) + onesum[i] + onerevsum[j]);
        }
    }
    println!("{}",max);
}

fn main() {
    inputv! {
        n:usize,
    }
    let a = input_vector::<usize>();
    let mut ans = 0;
    let one_count = a.iter().filter(|&&q| q == 1).count();
    for i in 0..n {
        for j in i + 1..=n {
            let zero = a[i..j].iter().filter(|&&q| q == 0).count();
            let one = j - i - zero;
            ans = std::cmp::max(ans, one_count + zero - one);
        }
    }
    println!("{}", ans);
}

//https://github.com/manta1130/competitive-template-rs

use input::*;

pub mod input {
    use std::cell::RefCell;
    use std::io;
    pub const SPLIT_DELIMITER: char = ' ';
    pub use std::io::prelude::*;

    #[macro_export]
    thread_local! {
        pub static INPUT_BUFFER:RefCell<std::collections::VecDeque<String>>=RefCell::new(std::collections::VecDeque::new());
    }

    #[macro_export]
    macro_rules! input_internal {
        ($x:ident : $t:ty) => {
            INPUT_BUFFER.with(|p| {
                if p.borrow().len() == 0 {
                    let temp_str = input_line_str();
                    let mut split_result_iter = temp_str
                        .split(SPLIT_DELIMITER)
                        .map(|q| q.to_string())
                        .collect::<std::collections::VecDeque<_>>();
                    p.borrow_mut().append(&mut split_result_iter)
                }
            });
            let mut buf_split_result = String::new();
            INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());
            let $x: $t = buf_split_result.parse().unwrap();
        };
        (mut $x:ident : $t:ty) => {
            INPUT_BUFFER.with(|p| {
                if p.borrow().len() == 0 {
                    let temp_str = input_line_str();
                    let mut split_result_iter = temp_str
                        .split(SPLIT_DELIMITER)
                        .map(|q| q.to_string())
                        .collect::<std::collections::VecDeque<_>>();
                    p.borrow_mut().append(&mut split_result_iter)
                }
            });
            let mut buf_split_result = String::new();
            INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());
            let mut $x: $t = buf_split_result.parse().unwrap();
        };
    }

    #[macro_export]
    macro_rules! inputv {
    ($i:ident : $t:ty) => {
        input_internal!{$i : $t}
    };
    (mut $i:ident : $t:ty) => {
        input_internal!{mut $i : $t}
    };
    ($i:ident : $t:ty $(,)*) => {
            input_internal!{$i : $t}
    };
    (mut $i:ident : $t:ty $(,)*) => {
            input_internal!{mut $i : $t}
    };
    (mut $i:ident : $t:ty,$($q:tt)*) => {
            input_internal!{mut $i : $t}
            inputv!{$($q)*}
    };
    ($i:ident : $t:ty,$($q:tt)*) => {
            input_internal!{$i : $t}
            inputv!{$($q)*}
    };
}

    pub fn input_all() {
        INPUT_BUFFER.with(|p| {
            if p.borrow().len() == 0 {
                let mut temp_str = String::new();
                std::io::stdin().read_to_string(&mut temp_str).unwrap();
                let mut split_result_iter = temp_str
                    .split_whitespace()
                    .map(|q| q.to_string())
                    .collect::<std::collections::VecDeque<_>>();
                p.borrow_mut().append(&mut split_result_iter)
            }
        });
    }

    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(clippy::match_wild_err_arm)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error",),
            };
            v.push(buf);
        }
        v
    }

    #[allow(clippy::match_wild_err_arm)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error",),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn num_of_1_before(i: &Vec<u32>, idx: usize) -> u32 {
    i.iter().take(idx).sum()
}

fn num_of_1_after(i: &Vec<u32>, idx: usize) -> u32 {
    i.iter().skip(idx + 1).sum()
}

fn max_num_of_1_flipped_after(i: &Vec<u32>, idx: usize) -> u32 {
    if 1 == *i.iter().nth(idx).unwrap() {
        return 0;
    }
    let targets = i.iter().skip(idx);
    let mut current_score = 0;
    let mut scores = Vec::new();
    for (local_index, value) in targets.enumerate() {
        if *value == 0 {
            current_score = current_score + 1;
        }
        scores.push(current_score + num_of_1_after(i, idx + local_index));
    }
    scores.into_iter().max().unwrap_or(0)
}

fn max_score(i: &Vec<u32>, idx: usize) -> u32 {
    num_of_1_before(i, idx) + max_num_of_1_flipped_after(i, idx)
}

fn main() {
    input! {
        n: usize,
        a: [u32; n],
    }

    let v = Vec::from(a);

    println!(
        "{}",
        (0..n).map(|idx| max_score(&v, idx)).max().unwrap_or(0)
    );
}

use std::io;
use std::cmp;

fn read_line() -> String {
    let mut line = String::new();
    match io::stdin().read_line(&mut line) {
        Ok(_) => line.trim().to_string(),
        _ => panic!("QQ"),
    }
}

fn main() {
    read_line();

    let mut cnt: i32 = 0;
    let mut min: i32 = 0;
    let mut cur: i32 = 0;
    let mut ans: i32 = -1;
    for x in read_line().split_whitespace().map(|x| x.parse::<i32>().unwrap()) {
        cnt += x;
        cur += if x == 1 { -1 } else { 1 };
        ans = cmp::max(ans, cur - min);
        min = cmp::min(min, cur);
    }

    println!("{}", ans + cnt);
}

struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

    fn next_n<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect()
    }

}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let arr: Vec<isize> = scan.next_n(n);
    let allones: usize = arr.iter().filter(|&&x| x==1).count();
    let total: isize = arr.iter().sum();
    // convert to an array in which Kadane can be used
    let arr2: Vec<isize> = arr.into_iter().map(|x| if x==1 { -1 } else { 1 }).collect();
    let mut cnt: isize = 0;
    let mut maxcnt: isize = 0;
    if allones == n {
        println!("{}", total-1);
        return;
    }
    for i in 0..n {
        cnt += arr2[i];
        if cnt < 0 { cnt = 0; }
        maxcnt = maxcnt.max(cnt);
    }
    println!("{}", total + maxcnt);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}

use std::cmp::max;
use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_t<T : FromStr>(stdin : &Stdin) -> T {
    let mut line = String::new();
    read_line(stdin, &mut line);
    parse_t(&line)
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn max_ones(xs : &Vec<i8>) -> i8 {
    let s = xs.iter().sum::<i8>();
    let mut ys = vec![];
    let one = 1;
    let minus_one = -1;
    for &x in xs.iter() {
        if x == 0 {
            ys.push(one);
        } else {
            ys.push(minus_one);
        }
    }
    let mut max_upto_i = ys[0];
    let mut max_ending_at_i = ys[0];
    for i in 1 .. ys.len() {
        let y = ys[i];
        max_ending_at_i = max(y, max_ending_at_i + y);
        max_upto_i = max(max_ending_at_i, max_upto_i);
    }
    s + max_upto_i
}

fn main() {
    let stdin = io::stdin();
    let _ : usize = read_t(&stdin);
    let mut xs = vec![];
    read_ts(&stdin, &mut xs);
    let result = max_ones(&xs);
    println!("{}", result);
}

use std::cmp::max;
use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_t<T : FromStr>(stdin : &Stdin) -> T {
    let mut line = String::new();
    read_line(stdin, &mut line);
    parse_t(&line)
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn max_ones(xs : &Vec<i8>) -> i8 {
    let mut ys = vec![];
    let one = 1;
    let minus_one = -1;
    let mut s = 0;
    for &x in xs.iter() {
        if x == 0 {
            ys.push(one);
        } else {
            ys.push(minus_one);
            s = s + one;
        }
    }
    let mut max_upto_i = ys[0];
    let mut max_ending_at_i = ys[0];
    for i in 1 .. ys.len() {
        let y = ys[i];
        max_ending_at_i = max(y, max_ending_at_i + y);
        max_upto_i = max(max_ending_at_i, max_upto_i);
    }
    s + max_upto_i
}

fn main() {
    let stdin = io::stdin();
    let _ : usize = read_t(&stdin);
    let mut xs = vec![];
    read_ts(&stdin, &mut xs);
    let result = max_ones(&xs);
    println!("{}", result);
}

use std::cmp::max;
use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_t<T : FromStr>(stdin : &Stdin) -> T {
    let mut line = String::new();
    read_line(stdin, &mut line);
    parse_t(&line)
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn max_ones(ys : &Vec<i8>) -> i8 {
    let one = 1;
    let minus_one = -1;
    let mut s = ys[0];
    let y_0 = if ys[0] == 0 { one } else { minus_one };
    let mut max_upto_i = y_0;
    let mut max_ending_at_i = y_0;
    for i in 1 .. ys.len() {
        let ys_i = ys[i];
        s = s + ys_i;
        let y = if ys_i == 0 { one } else { minus_one };
        max_ending_at_i = max(y, max_ending_at_i + y);
        max_upto_i = max(max_ending_at_i, max_upto_i);
    }
    s + max_upto_i
}

fn main() {
    let stdin = io::stdin();
    let _ : usize = read_t(&stdin);
    let mut xs = vec![];
    read_ts(&stdin, &mut xs);
    let result = max_ones(&xs);
    println!("{}", result);
}

fn solve() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let a: Vec<i32> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace().map(|s| s.parse().unwrap()).collect()
    };

    let mut ans = 0;
    for i in 0..n {
        for j in i..n {
            let mut tmp = a.clone();
            for k in i..j + 1 {
                tmp[k] = 1 - tmp[k];
            }
            ans = ans.max(tmp.iter().sum());
        }
    }

    println!("{}", ans);
}

fn main() {
    solve();
}

#![allow(unused_imports)]
use std::collections::{HashSet, HashMap};
use std::cmp::{min,max};
use std::io;
use std::str;

struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitWhitespace<'static>,
}
impl<R: io::BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self { reader, buf_str: vec![], buf_iter: "".split_whitespace() }
    }
    fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            // If we have another token in this line
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse"); // calls parse::<T>() on the current token and returns it.
            }

            // If we do not have another token in the line then
            // we should go to the next line.
            self.buf_str.clear(); // empty out the buffer that holds the current line
            self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read"); // read a new line into the buffer

            // create an iterator over the white space delimited strings of the current line
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str); // makes a string from utf8 characters in the current line
                std::mem::transmute(slice.split_whitespace()) // transmutes the memory in place
            }
        }
    }
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n = scan.token::<usize>();
    let mut s = vec![];
    for _ in 0..n {
        s.push(scan.token::<u8>());
    }
    let mut max: u8 = 0;

    for i in 0..n {
        for j in i..n {
            let mut curr = 0;
            for k in 0..n {
                curr += {
                    if k < i {s[k]}
                    else if k >= i && k <= j {1 - s[k]}
                    else {s[k]}
                }
            }
            max = u8::max(curr, max);
        }
    }
    writeln!(out, "{}", max);
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}

#![allow(unused_imports)]
#![allow(unused_macros)]
use std::io::{StdinLock, stdin, BufRead};
use std::collections::*;
use std::cmp::*;

fn scan_helper(lock : &mut StdinLock) -> String {
    let mut buffer = String::new();
    lock.read_line(&mut buffer).ok();
    buffer
}

macro_rules! scan {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .next().unwrap()
            .parse::<$t>().unwrap()
    });
    ($lock:ident, $($t:ty),+) => ({
        let buffer = scan_helper(&mut $lock);
        let mut iter = buffer.split_whitespace();
        ($(
            {
                iter.next().unwrap()
                    .parse::<$t>().unwrap()
            },
        )+)
    })
}

macro_rules! scan_iter {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect()
    })
}

trait Ext {
    fn idx(&self) -> usize;
    fn num(&self) -> i64;
}

macro_rules! ext {
    ($t:ty) => (
        impl Ext for $t {
            #[inline]
            fn idx(&self) -> usize {
                *self as usize
            }

            #[inline]
            fn num(&self) -> i64 {
                *self as i64
            }
        }
    )
}
ext!(i64);
ext!(usize);

#[derive(Copy, Clone, Debug)]
struct Pair {
    i : usize,
    cost : i64
}
impl PartialOrd for Pair {
    fn partial_cmp(&self, other : &Pair) -> Option<Ordering> {
        Some(self.cost.cmp(&other.cost))
    }
}

impl Ord for Pair {
    fn cmp(&self, other : &Pair) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

impl PartialEq for Pair {
    fn eq(&self, other : &Pair) -> bool {
        self.cost == other.cost
    }
}
impl Eq for Pair {}

fn main() {
    let stdin = stdin();
    let mut s = stdin.lock();
    let n = scan!(s, usize);
    let data : Vec<_> = scan_iter!(s, i64);
    let mut result = 0;

    for i in 0..n {
        for j in (i+1)..(n+1) {
            let mut count = 0;
            for k in 0..n {
                if k >= i && k <= j {
                    count += 1 - data[k];
                } else {
                    count += data[k];
                }
            }
            result = max(result, count);
        }
    }

    println!("{}", result);
}

// use rand::Rng;

use std::collections::*;
use std::io;

fn trim_newline(s: &mut String) {
    if s.ends_with('\n') {
        s.pop();
        if s.ends_with('\r') {
            s.pop();
        }
    }
}
macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        trim_newline(&mut input_line);
        input_line.parse::<$t>().unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let a = parse_input!(u64);
    let b = split_input!(u64);
    let mut best = 0;
    let mut cur = 0;
    let mut ones: u64 = b.iter().sum();
    if ones as usize == b.len() {
        ones -= 1;
    }
    for p in b.iter() {
        if *p == 0 {
            cur += 1;
            best = std::cmp::max(best, cur);
        } else if cur > 0 {
            cur -= 1;
        }
    }

    println!("{}", ones + best);
}

use std::io::{stdin, BufRead};

fn get_max_delta<T>(values: &Vec<T>) -> Option<(T, usize, usize)>
where
    T: Ord,
    T: Copy,
    T: std::ops::Sub<Output = T>,
{
    if values.len() <= 1 {
        return None;
    }

    let mut min_positions: Vec<usize> = Vec::new();
    let mut max_positions: Vec<usize> = Vec::new();

    min_positions.push(0);
    max_positions.push(0);

    for i in 1..(values.len() - 1) {
        let value = values[i];
        let prev_value = values[i - 1];
        let next_value = values[i + 1];

        if (value >= prev_value) && (value >= next_value) {
            max_positions.push(i);
        }
        if (value <= prev_value) && (value <= next_value) {
            min_positions.push(i);
        }
    }

    min_positions.push(values.len() - 1);
    max_positions.push(values.len() - 1);

    let mut max_delta: Option<(T, usize, usize)> = None;
    let mut max_position_index: usize = 0;

    for i in 0..min_positions.len() {
        let min_position = min_positions[i];
        let min_position_value = values[min_position];
        while max_positions[max_position_index] <= min_positions[i] {
            max_position_index += 1;
            if max_position_index >= max_positions.len() {
                break;
            }
        }
        if max_position_index >= max_positions.len() {
            break;
        }
        for j in max_position_index..max_positions.len() {
            let max_position = max_positions[j];
            let max_position_value = values[max_position];
            let delta_value = max_position_value - min_position_value;
            if let Some((max_delta_value, _max_delta_start, _max_delta_end)) = max_delta {
                if delta_value > max_delta_value {
                    max_delta = Some((delta_value, min_position, max_position));
                }
            } else {
                max_delta = Some((delta_value, min_position, max_position));
            }
        }
    }

    return max_delta;
}

fn get_best_score(values: &Vec<u8>) -> usize {
    let mut switch_scores: Vec<isize> = Vec::with_capacity(values.len() + 1);
    switch_scores.push(0);
    let mut current_switch_score: isize = 0;
    let mut base_score: usize = 0;
    for &value in values {
        if value == 0 {
            current_switch_score += 1;
        } else {
            current_switch_score -= 1;
            base_score += 1;
        }
        switch_scores.push(current_switch_score);
    }

    let (max_switch_score, _, _) = get_max_delta(&switch_scores).unwrap();

    return ((base_score as isize) + max_switch_score) as usize;
}

#[cfg(test)]
mod tests {
    use super::{get_best_score, get_max_delta};

    #[test]
    fn test_get_best_score_1() {
        assert_eq!(get_best_score(&vec![1, 0, 0, 1, 0]), 4);
    }
    #[test]
    fn test_get_best_score_2() {
        assert_eq!(get_best_score(&vec![1, 0, 0, 1]), 4);
    }
    #[test]
    fn test_get_best_score_3() {
        assert_eq!(get_best_score(&vec![1, 0, 1, 0, 1, 0]), 4);
    }
    #[test]
    fn test_get_best_score_4() {
        assert_eq!(get_best_score(&vec![1]), 0);
    }
    #[test]
    fn test_get_best_score_5() {
        assert_eq!(get_best_score(&vec![0]), 1);
    }

    fn do_test_max_delta(values: &Vec<i32>) {
        if values.len() <= 1 {
            assert_eq!(get_max_delta(values), None);
            return;
        }

        let mut max_delta: i32 = 0;
        for i in 0..values.len() {
            for j in (i + 1)..values.len() {
                let delta: i32 = values[j] - values[i];
                if delta > max_delta {
                    max_delta = delta;
                }
            }
        }

        let (result_max_delta, result_start, result_end) = get_max_delta(values).unwrap();
        assert_eq!(result_max_delta, max_delta);
        assert_eq!(values[result_end] - values[result_start], max_delta);
    }

    #[test]
    fn test_get_max_delta_1() {
        do_test_max_delta(&vec![1, 2, 7, 19, 20, 3, 0, -4, 4]);
    }
    #[test]
    fn test_get_max_delta_2() {
        do_test_max_delta(&vec![0, 0, 0, 3]);
    }
    #[test]
    fn test_get_max_delta_3() {
        do_test_max_delta(&vec![1]);
    }
}

fn main() {
    let stdin = stdin();
    let mut stdin_lock = stdin.lock();

    {
        let mut skip_buffer = String::new();
        stdin_lock.read_line(&mut skip_buffer).unwrap();
    }
    let mut string_buffer = String::new();
    stdin_lock.read_line(&mut string_buffer).unwrap();
    let values: Vec<u8> = string_buffer
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<u8>().unwrap())
        .collect();

    let best_score: usize = get_best_score(&values);
    println!("{}", best_score);
}

// 2018-10-12 13:59
fn main() {
    let _ = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim()
            .split(" ")
            .map(|s| s.parse::<i32>().unwrap())
            .collect()
    };

    let n = v.len();
    let orig = v.iter().filter(|&x| *x == 1).count() as i32;

    let mut dp = vec![vec![0; n + 1]; n + 1];
    let mut inc = 0;
    for i in 0..n {
        for j in i + 1..n + 1 {
            dp[i][j] = {
                if v[j - 1] == 0 {
                    dp[i][j - 1] + 1
                } else {
                    dp[i][j - 1]
                }
            };
            inc = std::cmp::max(inc, dp[i][j] * 2 - (j - i) as i32);
        }
    }
    if inc == 0 {
        println!("{:?}", 0);
    } else {
        println!("{:?}", inc + orig);
    }
}

// 2018-10-12 13:59
fn main() {
    let _ = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim()
            .split(" ")
            .map(|s| s.parse::<i32>().unwrap())
            .collect()
    };

    let n = v.len();
    let orig = v.iter().filter(|&x| *x == 1).count() as i32;

    let mut dp = vec![vec![0; n + 1]; n + 1];
    let mut inc = 0;
    for i in 0..n {
        for j in i + 1..n + 1 {
            dp[i][j] = {
                if v[j - 1] == 0 {
                    dp[i][j - 1] + 1
                } else {
                    dp[i][j - 1]
                }
            };
            inc = std::cmp::max(inc, dp[i][j] * 2 - (j - i) as i32);
        }
    }
    println!("{:?}", inc + orig);
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n : usize = s.trim().parse().unwrap();
    s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let ints:Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut onesum : Vec<i32> = vec![0];
    let mut onerevsum : Vec<i32> = vec![0];
    let mut sum = 0;
    let mut revsum = 0;
    let mut newints : Vec<i32> = vec![ints[0]];
    let mut newintscount : Vec<i32> = vec![if ints[0]==0 {1} else {0}];
    let mut lastnum=ints[0];

    for i in 0..n {
        *onesum.last_mut().unwrap() = sum;
        *onerevsum.first_mut().unwrap() = revsum;
        sum+=ints[i];
        revsum+=ints[n-i-1];
        if ints[i] == lastnum {
            *(newintscount.last_mut().unwrap())+=if ints[i]==0 {1} else{0};
        } else {
            onesum.push(0);
            onerevsum.insert(0,0);
            newints.push(ints[i]);
            newintscount.push(if ints[i]==0 {1} else {0});
        }
        lastnum = ints[i];
    }
    *onesum.last_mut().unwrap() = sum;
    *onerevsum.first_mut().unwrap() = revsum;

//    println!("{:?}",newints);
//    println!("{:?}",newintscount);
//    println!("{:?}",onesum);
//    println!("{:?}",onerevsum);

    let mut max = 0;

    for i in 0..(newints.len()) {
        for j in i..(newints.len()) {
            if newints[i] == 0 && newints[j] == 0 {
                let subsum = &newintscount[i..=j].iter().fold(0, |acc, x| acc+x) + onesum[i] + onerevsum[j];
//                println!("slice={:?} sum={}",&newints[i..=j],subsum);
                max = std::cmp::max(max, subsum);
            }
        }
    }
    println!("{}",max);

}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n : usize = s.trim().parse().unwrap();
    s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let ints:Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut onesum : Vec<i32> = vec![0];
    let mut onerevsum : Vec<i32> = vec![0];
    let mut sum = 0;
    let mut revsum = 0;
    let mut newints : Vec<i32> = vec![ints[0]];
    let mut newintscount : Vec<i32> = vec![0];
    let mut lastnum=ints[0];

    for i in 0..n {
        *onesum.last_mut().unwrap() = sum;
        *onerevsum.first_mut().unwrap() = revsum;
        sum+=ints[i];
        revsum+=ints[n-i-1];
        if ints[i] == lastnum {
            *(newintscount.last_mut().unwrap())+=if ints[i]==0 {1} else{0};
        } else {
            onesum.push(0);
            onerevsum.insert(0,0);
            newints.push(ints[i]);
            newintscount.push(if ints[i]==0 {1} else {0});
        }
        lastnum = ints[i];
    }
    *onesum.last_mut().unwrap() = sum;
    *onerevsum.first_mut().unwrap() = revsum;

//    println!("{:?}",newints);
//    println!("{:?}",newintscount);
//    println!("{:?}",onesum);
//    println!("{:?}",onerevsum);

    let mut max = 0;

    for i in 0..(newints.len()) {
        for j in i..(newints.len()) {
            if newints[i] == 0 && newints[j] == 0 {
                let subsum = &newintscount[i..=j].iter().fold(0, |acc, x| acc+x) + onesum[i] + onerevsum[j];
//                println!("slice={:?} sum={}",&newints[i..=j],subsum);
                max = std::cmp::max(max, subsum);
            }
        }
    }
    println!("{}",max);

}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n : usize = s.trim().parse().unwrap();
    s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let ints:Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut onesum : Vec<i32> = vec![0];
    let mut onerevsum : Vec<i32> = vec![0];
    let mut sum = 0;
    let mut revsum = 0;
    let mut newints : Vec<i32> = vec![ints[0]];
    let mut newintscount : Vec<i32> = vec![0];
    let mut lastnum=ints[0];

    for i in 0..n {
        *onesum.last_mut().unwrap() = sum;
        *onerevsum.first_mut().unwrap() = revsum;
        sum+=ints[i];
        revsum+=ints[n-i-1];
        if ints[i] == lastnum {
            *(newintscount.last_mut().unwrap())+=if ints[i]==0 {1} else{0};
        } else {
            onesum.push(0);
            onerevsum.insert(0,0);
            newints.push(ints[i]);
            newintscount.push(if ints[i]==0 {1} else {0});
        }
        lastnum = ints[i];
    }
    *onesum.last_mut().unwrap() = sum;
    *onerevsum.first_mut().unwrap() = revsum;

//    println!("{:?}",newints);
//    println!("{:?}",newintscount);
//    println!("{:?}",onesum);
//    println!("{:?}",onerevsum);

    if newints.len()==1 {
        if newints[0] == 1 {
             println!("{}",n-1);
        } else {
             println!("{}", n);
        }
    } else {
    let mut max = 0;

    for i in 0..(newints.len()) {
        for j in i..(newints.len()) {
            if newints[i] == 0 && newints[j] == 0 {
                let subsum = &newintscount[i..=j].iter().fold(0, |acc, x| acc+x) + onesum[i] + onerevsum[j];
//                println!("slice={:?} sum={}",&newints[i..=j],subsum);
                max = std::cmp::max(max, subsum);
            }
        }
    }
    println!("{}",max);
    }
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

struct State(u32, u32);

fn main() {
    input! {
        n: usize,
        a: [u8; n],
    }

    let mut state = State(0, 0);
    let num_of_1 = a.iter().filter(|x| **x == 1).count();

    for x in a {
        state = if x == 1 {
            State(std::cmp::max(state.0, state.1), 0)
        } else {
            State(state.0, state.1 + 1)
        };
    }
    println!("{}", num_of_1 as u32 + state.0);
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

struct State(u32, u32);

fn main() {
    input! {
        n: usize,
        a: [u8; n],
    }

    let mut state = State(0, 0);
    let num_of_1 = a.iter().filter(|x| **x == 1).count();

    for x in a {
        state = if x == 1 {
            State(std::cmp::max(state.0, state.1), 0)
        } else {
            State(state.0, state.1 + 1)
        };
    }

    state = if state.1 != 0 {
        State(std::cmp::max(state.0, state.1), 0)
    } else {
        state
    };

    if state.0 == 0 {
        println!("{}", n - 1);
    } else {
        println!("{}", num_of_1 as u32 + state.0);
    }
}

struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

    fn next_n<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect()
    }

}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let arr: Vec<isize> = scan.next_n(n);
    let total: isize = arr.iter().sum();
    // convert to an array in which Kadane can be used
    let arr2: Vec<isize> = arr.into_iter().map(|x| if x==1 { -1 } else { 1 }).collect();
    let mut cnt: isize = 0;
    let mut maxcnt: isize = 0;
    for i in 0..n {
        cnt += arr2[i];
        if cnt < 0 { cnt = 0; }
        maxcnt = maxcnt.max(cnt);
    }
    println!("{}", total + maxcnt);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}

#![allow(unused_imports)]
#![allow(unused_macros)]
use std::io::{StdinLock, stdin, BufRead};
use std::collections::*;
use std::cmp::*;

fn scan_helper(lock : &mut StdinLock) -> String {
    let mut buffer = String::new();
    lock.read_line(&mut buffer).ok();
    buffer
}

macro_rules! scan {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .next().unwrap()
            .parse::<$t>().unwrap()
    });
    ($lock:ident, $($t:ty),+) => ({
        let buffer = scan_helper(&mut $lock);
        let mut iter = buffer.split_whitespace();
        ($(
            {
                iter.next().unwrap()
                    .parse::<$t>().unwrap()
            },
        )+)
    })
}

macro_rules! scan_iter {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect()
    })
}

trait Ext {
    fn idx(&self) -> usize;
    fn num(&self) -> i64;
}

macro_rules! ext {
    ($t:ty) => (
        impl Ext for $t {
            #[inline]
            fn idx(&self) -> usize {
                *self as usize
            }

            #[inline]
            fn num(&self) -> i64 {
                *self as i64
            }
        }
    )
}
ext!(i64);
ext!(usize);

#[derive(Copy, Clone, Debug)]
struct Pair {
    i : usize,
    cost : i64
}
impl PartialOrd for Pair {
    fn partial_cmp(&self, other : &Pair) -> Option<Ordering> {
        Some(self.cost.cmp(&other.cost))
    }
}

impl Ord for Pair {
    fn cmp(&self, other : &Pair) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

impl PartialEq for Pair {
    fn eq(&self, other : &Pair) -> bool {
        self.cost == other.cost
    }
}
impl Eq for Pair {}

fn main() {
    let stdin = stdin();
    let mut s = stdin.lock();
    let _ = scan!(s, usize);
    let mut data : Vec<_> = scan_iter!(s, i64);
    let mut i = 0;
    let mut j = data.len() - 1;

    while i < data.len() && data[i] == 1 {
        i += 1;
    }
    while j > 0 && data[j] == 1 {
        j -= 1;
    }

    for k in i..(j+1) {
        data[k] = 1 - data[k];
    }
    let result = data.iter().fold(0, |c, x| c + x);

    println!("{}", result);
}

#![allow(unused_imports)]
#![allow(unused_macros)]
use std::io::{StdinLock, stdin, BufRead};
use std::collections::*;
use std::cmp::*;

fn scan_helper(lock : &mut StdinLock) -> String {
    let mut buffer = String::new();
    lock.read_line(&mut buffer).ok();
    buffer
}

macro_rules! scan {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .next().unwrap()
            .parse::<$t>().unwrap()
    });
    ($lock:ident, $($t:ty),+) => ({
        let buffer = scan_helper(&mut $lock);
        let mut iter = buffer.split_whitespace();
        ($(
            {
                iter.next().unwrap()
                    .parse::<$t>().unwrap()
            },
        )+)
    })
}

macro_rules! scan_iter {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect()
    })
}

trait Ext {
    fn idx(&self) -> usize;
    fn num(&self) -> i64;
}

macro_rules! ext {
    ($t:ty) => (
        impl Ext for $t {
            #[inline]
            fn idx(&self) -> usize {
                *self as usize
            }

            #[inline]
            fn num(&self) -> i64 {
                *self as i64
            }
        }
    )
}
ext!(i64);
ext!(usize);

#[derive(Copy, Clone, Debug)]
struct Pair {
    i : usize,
    cost : i64
}
impl PartialOrd for Pair {
    fn partial_cmp(&self, other : &Pair) -> Option<Ordering> {
        Some(self.cost.cmp(&other.cost))
    }
}

impl Ord for Pair {
    fn cmp(&self, other : &Pair) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

impl PartialEq for Pair {
    fn eq(&self, other : &Pair) -> bool {
        self.cost == other.cost
    }
}
impl Eq for Pair {}

fn main() {
    let stdin = stdin();
    let mut s = stdin.lock();
    let _ = scan!(s, usize);
    let mut data : Vec<_> = scan_iter!(s, i64);
    let mut i = 0;
    let mut j = data.len() - 1;

    while i < data.len() - 1 && data[i] == 1 {
        i += 1;
    }
    while j > 0 && data[j] == 1 {
        j -= 1;
    }

    if i > j {
        i = 0; j = 0;
    }

    for k in i..(j+1) {
        data[k] = 1 - data[k];
    }
    let result = data.iter().fold(0, |c, x| c + x);

    println!("{}", result);
}

// use rand::Rng;

use std::collections::*;
use std::io;

fn trim_newline(s: &mut String) {
    if s.ends_with('\n') {
        s.pop();
        if s.ends_with('\r') {
            s.pop();
        }
    }
}
macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        trim_newline(&mut input_line);
        input_line.parse::<$t>().unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let a = parse_input!(u64);
    let b = split_input!(u64);
    let mut best = 0;
    let mut cur = 0;
    let ones: u64 = b.iter().sum();
    for p in b.iter() {
        if *p == 0 {
            cur += 1;
            best = std::cmp::max(best, cur);
        } else if cur > 0 {
            cur -= 1;
        }
    }

    println!("{}", ones + best);
}