Iahub got bored, so he invented a game to be played on paper. He writes n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and flips all values ak for which their positions are in range [i, j] (that is i ≤ k ≤ j). Flip the value of x means to apply operation x = 1 - x.The goal of the game is that after exactly one move to obtain the maximum number of ones. Write a program to solve the little game of Iahub.

The first line of the input contains an integer n (1 ≤ n ≤ 100). In the second line of the input there are n integers: a1, a2, ..., an. It is guaranteed that each of those n values is either 0 or 1.

Print an integer — the maximal number of 1s that can be obtained after exactly one move.

NoteIn the first case, flip the segment from 2 to 5 (i = 2, j = 5). That flip changes the sequence, it becomes: [1 1 1 0 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1].In the second case, flipping only the second and the third element (i = 2, j = 3) will turn all numbers into 1.

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(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);
}

#![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);
}


The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.

The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.

If the word t is a word s, written reversely, print YES, otherwise print NO.

fn main() {
    let mut line1 = String::new();
    let mut line2 = String::new();
    std::io::stdin().read_line(&mut line1).unwrap();
    std::io::stdin().read_line(&mut line2).unwrap();
    let rev = line2.chars().rev().collect::<String>();
    println!("{}", if rev.trim() == line1.trim() { "YES" } else { "NO"});
}

fn main() {
    // The input text need to be translated
    let mut s = String::new();
    let mut t = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    std::io::stdin().read_line(&mut t).unwrap();

    let vs: Vec<char> = s.trim().chars().collect();
    let vt: Vec<char> = t.trim().chars().collect();

    let mut b: bool = true;
    if vs.len() != vt.len() {
        b = false;
    } else {
        // Check duplicate characters
        let mut p: usize = 0;
        let mut q: usize = vt.len() - 1;
        loop {
            if vs[p] != vt[q] {
                b = false;
                break;
            }

            if p >= vs.len() || q <= 0 {
                break;
            }

            p += 1;
            q -= 1;
        }
    }

    // Display the result
    if b {
        println!("YES");
    } else {
        println!("NO");
    }
}

//! http://codeforces.com/contest/41/problem/A

#[macro_export]
macro_rules! scanln {
  ($($var:ident : $ty:path),+) => {
    $(let $var: $ty;)+
    {
      use std::io;
      let mut __buf = String::new();
      io::stdin().read_line(&mut __buf).unwrap();
      let mut eles = __buf.split_whitespace();
      $($var = Scan::scan(&mut eles);)+
    }
  }
}

pub trait Scan {
  fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str>;
}

macro_rules! impl_scan_single {
  ($ty:ty) => {
    impl Scan for $ty {
      fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
        let next = eles.next().unwrap();
        match next.parse() {
          Ok(res) => res,
          Err(_) => panic!()
        }
      }
    }
  }
}

impl_scan_single!(u8);
impl_scan_single!(u16);
impl_scan_single!(u32);
impl_scan_single!(u64);
impl_scan_single!(usize);
impl_scan_single!(i8);
impl_scan_single!(i16);
impl_scan_single!(i32);
impl_scan_single!(i64);
impl_scan_single!(isize);
impl_scan_single!(String);

const __IMPL_SCAN_FOR_VEC: () = {
  use std::str::FromStr;
  impl<T> Scan for Vec<T> where T: FromStr {
    fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
      eles.map(|str| match str.parse() {
        Ok(res) => res,
        Err(_) => panic!()
      }).collect()
    }
  }
};

// -----------------------------------------------------------------------------

fn main() {
  scanln!(s: String);
  scanln!(t: String);
  let v: String = t.chars().rev().collect();
  println!("{}",
    if &s == &v {
      "YES"
    } else {
      "NO"
    }
  );
}

#[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)] fn strarr() -> Vec<String> {
    let mut inp = String::new();
    stdin().read_line(&mut inp).ok();
    inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).map(|x| x.to_string()).collect() }
#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{
    let s = strarr(); let mut cnt : usize = 0;
    fn next<T>(cnt: &mut usize, p: &Vec<String>) -> 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 s = strarr(); let mut v = Vec::new();
    for i in 0..$n { v.push(s[i as usize].parse::<$T>().unwrap()); } v
    }}; }

///////////////////////////////////////////////////////////////////////////////

fn main()
{
    let s = scan!(String);
    let t = scan!(String);
    println!("{}", if s.chars().rev().collect::<Vec<char>>() == t.chars().collect::<Vec<char>>() { "YES" } else { "NO" });
}

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

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

    io::stdin().read_line(&mut s).expect("failed to read");
    io::stdin().read_line(&mut t).expect("failed to read");

    s = s.trim().to_string();
    t = t.trim().to_string();

    if s.len() != t.len() {
        print!("NO");
        io::stdout().flush().expect("failed to flush");
        return;
    }
    for i in 0..(s.len()) {
        let char_s = &s[i..(i + 1)];
        let char_t = &t[(t.len() - i - 1)..(t.len() - i)];
        if char_s != char_t {
            print!("NO");
            io::stdout().flush().expect("failed to flush");
            return;
        }
    }

    print!("YES");
    io::stdout().flush().expect("failed to flush");
}

use std::io;

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

fn main() {
    let (t, s) = (input(), input());
    if t == s.chars().rev().collect::<String>() {
        println!("YES");
    } else {
        println!("NO");
    }
}

//spnauti-rust
#[allow(unused_imports)]
use std::io::{self,Read};

struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T : 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 main() {
    let mut input = WordReader::from_stdin();
    if input.s() == input.s().chars().rev().collect::<String>() {
        println!("YES");
    } else {
        println!("NO");
    }
}

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

    let mut s2 = String::new();
    std::io::stdin().read_line(&mut s2);
    let s2 = s2.trim();

    let s1_reversed: String = s1.chars().rev().collect();
    if s1_reversed.eq(s2) {
        println!("YES");
    } else {
        println!("NO");
    }
}

use std::io;

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

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

    first_input = first_input.trim().parse().unwrap();
    second_input = second_input.trim().parse().unwrap();

    let second_input: String = second_input.chars().rev().collect();

    if first_input.eq(&second_input) {
        println!("YES");
    } else {
        println!("NO");
    }
}

use std::io;

fn main() {
    let mut buf1 = String::new();
    io::stdin().read_line(&mut buf1).unwrap();
    let buf1_rev = buf1.trim().chars().rev().collect::<String>();

    let mut buf2 = String::new();
    io::stdin().read_line(&mut buf2).unwrap();
    if buf2.trim() == buf1_rev {
        println!("YES");
        return;
    }
    println!("NO");
}

use std::io;

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

    let mut t = String::new();
    io::stdin().read_line(&mut t).unwrap();
    let t: String = t.chars().rev().collect();

    if s.trim() == t.trim() {
        println!("YES");
    } else {
        println!("NO");
    }
}

use std::io;

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

fn main() {

    let line1 = read_line();
    let line2 = read_line();
    let correct = line1.len() == line2.len() && line1.trim().chars().rev().zip(line2.trim().chars()).all(|(a, b)| a == b);

    print!("{}", if correct { "YES" } else { "NO" });
}

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 main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let mut from: String = read(sin);
    let mut to: String = read(sin);

    let mut from = from.as_str().chars().rev();
    let mut to = to.as_str().chars();

    if from.zip(to).map(|x| x.0 != x.1).filter(|x| *x).count() == 0 {
        println!("YES")
    } else {
        println!("NO");
    }
}

fn main(){
    let mut line=String::new();
    let mut translated=String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line=line.trim().chars().rev().collect();
    std::io::stdin().read_line(&mut translated).unwrap();
    print!("{}",if translated.trim()==line{"YES"}else{"NO"});
}

fn main() {
    let word = get_input();
    let their_rev = get_input();
    let is_correct = their_rev == word.chars().rev().collect::<String>();
    println!("{}", if is_correct { "YES" } else { "NO" });

}

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

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

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

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

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

    let s: String = s.trim().chars().rev().collect();

    let mut t = String::new();

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

    let t = t.trim();

    if s == t {
        println!("YES");
    } else {
        println!("NO");
    }

}

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 mut input = get_input().trim().to_string();

    let mut input2 = get_input().trim().to_string();

    let res: String = input.chars().rev().collect();

    if input2 == res {
        println!("YES");
    } else {
        println!("NO");
    }

    Ok(())
}

use std::io;

fn main() {
    let mut s1 = String::new();
    let mut s2 = String::new();
    io::stdin().read_line(&mut s1).unwrap();
    io::stdin().read_line(&mut s2).unwrap();
    s1 = s1.trim().to_string();
    s2 = s2.trim().to_string();
    let n = s1.len();
    let mut flag = true;
    for i in 0..n {
        let c1 = s1.chars().nth(i);
        let c2 = s2.chars().nth(n-1-i);
        if c1 != c2 {
            flag = false;
        }
    }
    if flag {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn main() {
    let first_string = read_line();
    let second_string = read_line();

    if second_string == first_string.chars().rev().collect::<String>() {
        println!("YES");
    } else {
        println!("NO");
    }

}

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

    input.trim().to_string()
}

use std::str::FromStr;

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 (s, t): (String, String) = (read_str(), read_str());
    if s.chars().rev().collect::<String>() == t { println!("YES"); }
    else { println!("NO"); }
}

// http://codeforces.com/problemset/problem/41/A

use std::io::{Read, Write, stdin, stdout};

pub struct Scanner<U: Sized + Read> {
    pub buffer: Vec<String>,
    pub reader: U,
}
impl<U: Sized + Read> Scanner<U> {
    pub fn next_line<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();
        //     self.reader.read_to_string(&mut input).expect("Failed read");
        //     self.buffer = input.lines().rev().map(String::from).collect();
        // }
        if self.buffer.is_empty() {
            let mut input = String::new();
            self.reader.read_to_string(&mut input).expect("Failed read");
            self.buffer = input.lines().rev().map(String::from).collect();
        }
        self.buffer
            .pop()
            .unwrap()
            .parse()
            .ok()
            .expect("Failed parse")
    }

    pub fn new(reader: U) -> Self {
        Scanner {
            buffer: vec![],
            reader,
        }
    }
}

pub fn solution_of_p41a(input: &mut dyn Read, out: &mut dyn Write) {
    let mut scanner = Scanner::new(input);
    let s1 = scanner.next_line::<String>();
    let s2 = scanner.next_line::<String>();

    if is_translation(s1, s2) {
        write!(out, "YES").ok();
    } else {
        write!(out, "NO").ok();
    }
}

fn is_translation(s1: String, s2: String) -> bool {
    if s1.len() != s2.len() {
        return false;
    }
    let l = s1.len();
    for i in 0..l {
        if s1[i..=i] != s2[l - i - 1..=l - i - 1] {
            return false;
        }
    }
    true
}

fn main() {
    solution_of_p41a(&mut stdin(), &mut stdout());
}

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 main() {
    let stdin = io::stdin();
    let mut s = String::new();
    let mut t = String::new();
    read_line(&stdin, &mut s);
    read_line(&stdin, &mut t);
    let mut c_s = s.trim().chars();
    let mut c_t = t.trim().chars();
    let mut is_translation = false;
    loop {
        let x_s = c_s.next();
        let x_t = c_t.next_back();
        if x_s.is_none() && x_t.is_none() {
            is_translation = true;
            break;
        } else if x_s.is_some() && x_t.is_some() {
            let u_x_s = x_s.unwrap();
            let u_x_t = x_t.unwrap();
            if u_x_s == u_x_t {
                // Do nothing ...
            } else {
                break;
            }
        } else {
            break;
        }
    }
    if is_translation {
        println!("YES");
    } else {
        println!("NO");
    }
}

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, 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")
    };
}

fn main() {
    input! {
        s : String,
        t : String,
    };
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().rev().collect();
    let n = s.len();
    for i in 0..n {
        if s.get(i) != t.get(i) {
            println!("NO");
            return;
        }
    }
    println!("YES");
}

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

    line
}

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

    let s = String::from(s.trim());
    let t:String = String::from(t.trim()).chars().rev().collect();

    println!("{}", if s == t {"YES"} else {"NO"});
}

use std::io;

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

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

	if translation == word.chars().rev().collect::<String>() {
		println!("YES");
	} else {
		println!("NO");
	}
}

#![allow(non_snake_case, unused_imports)]

// 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::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){

    input!{
        S: chars,
        T: chars
    }

    let mut ans = "YES";
    for i in 0..S.len(){
        if S[i] != T[T.len()-1-i]{
            ans = "NO";
            break;
        }
    }

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

use std::io;

fn main() {
    let mut first = String::new();
    io::stdin().read_line(&mut first).unwrap();
    first = first.trim().to_string();
    let mut second = String::new();
    io::stdin().read_line(&mut second).unwrap();
    second = second.trim().chars().rev().collect();

    if first.contains(&second) {
        println!("YES");
    } else {
        println!("NO");
    }
}

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().chars().rev().collect::<String>();

    if s == t {
        println!("YES");
    } else {
        println!("NO");
    }

}

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 c = a.chars().rev().collect::<String>();

    writeln!(out, "{}", if b == c { "YES" } else { "NO" }).expect("fail");
}

use std::io;

fn main() {

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

    let vector: Vec<&str> = input.split("\n").collect();
    let second_vector: String = vector[1].chars().rev().collect();

    if vector[0].to_string().eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO");
    }

}

use std::io;

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

    let vector: Vec<&str> = input.split("\r\n").collect();
    let first_vector = vector[0].to_string();
    let second_vector: String = vector[1].trim().chars().rev().collect();

    //println!("{:?}", vector);

    if first_vector.eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO");
    }
}

use std::io;

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

    io::stdin().read_line(&mut x).expect("error");

    if x.len() <= 100 && !x.contains(" ") {
        let v: Vec<&str> = x.split("\n").collect();

        let mut z: String = String::from("");
        let mut index = 0;
        let mut a: &str = "";

        for y in v {
            if index == 0 {
                z = y.chars().rev().collect();
                index += 1;
            } else {
                a = y;
            }
        }

        if !z.eq_ignore_ascii_case(a) {
            println!("YES");
        } else {
            println!("NO");
        }

    }

}

use std::io;

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

    let vector: Vec<&str> = input.split("\r").collect();
    let first_vector = vector[0].to_string();
    let second_vector: String = vector[1].trim_start().chars().rev().collect();

    if first_vector.eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO");
    }
}

use std::io;

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

    io::stdin().read_line(&mut x).expect("error");

    if x.len() <= 100 && !x.contains(" ") {
        let v: Vec<&str> = x.split("\n").collect();

        let mut z: String = String::from("");
        let mut index = 0;
        let mut a: &str = "";

        for y in v {
            if index == 0 {
                z = y.chars().rev().collect();
                index += 1;
            } else {
                a = y;
            }
        }

        let g = z.as_str();

        if !z.eq_ignore_ascii_case(a) && g.eq_ignore_ascii_case(a) {
                println!("YES");
        } else {
            println!("NO");
        }

    }

}

use std::io;

fn main() {

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

    let vector: Vec<&str> = string.split("\n").collect();
    let second_vector: String = vector[1].chars().rev().collect();

    if vector[0].to_string().eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO {} - {}", vector[0], second_vector);
    }

}

use std::io;

fn main() {

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

    let vector: Vec<&str> = string.split("\n").collect();
    let second_vector: String = vector[1].chars().rev().collect();

    if vector[0].to_string().eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO");
    }

}

use std::io;

fn main() {

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

    let vector: Vec<&str> = input.split("\n").collect();
    let second_vector: String = vector[1].trim().chars().rev().collect();

    if vector[0].trim().to_string().eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO");
    }

}

use std::io;

fn main() {

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

    let vector: Vec<&str> = string.split("\n").collect();

    if vector[1].chars().eq(vector[0].chars().rev()) {
        println!("YES");
    } else {
        println!("NO");
    }

}

use std::io;

fn main() {

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

    let vector: Vec<&str> = input.split("\n").collect();
    let first_vector = vector[0].to_string();
    let second_vector: String = vector[1].trim().chars().rev().collect();

    if first_vector.eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO");
    }

    println!("{:?}", vector);

    println!("1. {}", first_vector);
    println!("2. {}", second_vector);
}

use std::io;

fn main() {

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

    let vector: Vec<&str> = string.split("\n").collect();
    let second_vector: String = vector[1].chars().rev().collect();

    if vector[0].to_string().eq(&second_vector) {
        println!("YES");
    } else {
        println!("NO {} - {}", vector[0], vector[1]);
    }

    println!("{:?}", vector);
}


One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.Every day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.Vasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.Can you help him?

The single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.

Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got. Keep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.

NoteIn the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day.

fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("INPUT::read line failed");

    let mut input = input.trim().split(' ');
    let mut shoes = [i32::default();2];
    shoes[0] = input.next().unwrap().parse::<i32>().unwrap();
    shoes[1] = input.next().unwrap().parse::<i32>().unwrap();

    if shoes[0] > shoes[1] {
        shoes.swap(0, 1);
    }

    let fashion = shoes[0];
    let normal = (shoes[1] - fashion) / 2;

    println!("{} {}", fashion, normal);

}

use std::cmp::{max, min};
use std::io::stdin;

pub fn main() {
    let (red, blue) = {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        let a: Vec<i32> = buf
            .trim()
            .split_ascii_whitespace()
            .map(|c| c.parse().unwrap())
            .collect();
        (a[0], a[1])
    };
    let hip_pairs = min(red, blue);
    let normal_pairs = (max(red, blue) - hip_pairs) / 2;
    println!("{} {}", hip_pairs, normal_pairs);
}

fn input_pair() -> Vec<u8> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|elem| elem.parse().unwrap()).collect()
}

fn main() {
    let input = input_pair();
    let (r, b) = (input[0], input[1]);
    let s = r.min(b);
    let l = (r.max(b) - s) / 2;
    println!("{} {}", s, l);
}

type Pair = (u8, u8);
fn input_pair() -> Pair {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let buf: Vec<u8> = buf.trim().split_whitespace().map(|elem| elem.parse().unwrap()).collect();
    (buf[0], buf[1])
}

fn main() {
    let (r, b) = input_pair();
    println!("{} {}", r.min(b), (r.max(b) - r.min(b)) / 2);
}

//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 a = input.i();
    let b = input.i();
    let min = std::cmp::min(a, b);
    println!("{} {}", min, (a + b - 2 * min) / 2);
}

macro_rules! readln {
    () => {{
        use std::io;

        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim().to_string()
    }};
    ( $t:ty ) => {{
        let input = readln!();
        input.parse::<$t>().unwrap()
    }};
    ( $( $t:ty ),+ ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        (
            $(
                input.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    }}
}

macro_rules! readvec {
    ( $t:ty ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        let mut result = Vec::new();
        for elem in input {
            result.push(elem.parse::<$t>().unwrap());
        }
        result
    }}
}

fn main() {
    let (a,b) = readln!(i32,i32);
    println!("{} {}",std::cmp::min(a,b),(a+b-std::cmp::min(a,b)*2)/2);
}

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

fn main() {
    let stdin = io::stdin();
    let mut iterator = stdin.lock().lines();
    let line: String;
    let numbers: Vec<i32>;
    let (min, max): (i32, i32);

    line = iterator.next().unwrap().unwrap();
    numbers = line
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    match numbers.iter().min() {
        Some(number) => min = *number,
        None => min = 0,
    }
    match numbers.iter().max() {
        Some(number) => max = *number,
        None => max = 0,
    }

    println!("{} {}", min, (max-min)/2);
}

use std::io::stdin;
fn main() {
	let mut s = String::new();
	stdin().read_line(&mut s).unwrap();
	let a: Vec<i64> = s
		.split_whitespace()
		.map(|x| x.parse().unwrap())
		.collect();
	println!("{} {}", std::cmp::min(a[0], a[1]), (a[0] - a[1]).abs()/2)
}

// {{{ by shik

use std::io;

#[allow(dead_code)]
fn gets() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(unused_macros)]
macro_rules! R {
    ( $ty:ty, ... ) => {
        gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap()).collect::<Vec<_>>()
    };
    ( $($ty:ty),* ) => {{
        let line = gets();
        let mut it = line.split_whitespace();
        ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )
    }}
}

#[allow(unused_macros)]
macro_rules! W {
    ( $x:expr ) => {{
        println!("{}", $x);
    }};
    ( $x:expr, $($xs:expr),* ) => {{
        print!("{} ", $x);
        W!($($xs),*);
    }}
}

#[allow(unused_macros)]
macro_rules! join {
    ($x:expr, $($xs:expr),*; $sep:expr) => { concat!($x, $($sep, $xs),*) }
}

#[allow(unused_macros)]
macro_rules! dump {
    ($($x:expr),*) => {
        eprintln!(join!($(concat!(stringify!($x), " = {:?}")),*; ", "), $($x),*);
    }
}

// }}}

use std::cmp;

fn main() {

    let (a, b) = R!(usize, usize);

    println!("{} {}", cmp::min(a, b), (cmp::max(a, b) - cmp::min(a, b)) / 2);

}

use std::error::Error;
use std::io;

fn get_line() -> io::Result<String> {
	let mut buffer = String::new();
	io::stdin().read_line(&mut buffer)?;
	Ok(buffer)
}

fn main() -> Result<(), Box<dyn Error>> {
	let input = get_line()?
		.split_whitespace()
		.map(|s| s.parse::<u32>())
		.collect::<Result<Vec<_>, _>>()?;
	let diff = input[0].min(input[1]);
	let same = (input[0].max(input[1]) - diff) / 2;
	print!("{} {}", diff, same);
	Ok(())
}

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 main() {
    input! {
        red_socks: u32,
        blue_socks: u32,
    }

    let x = std::cmp::min(red_socks, blue_socks);
    let y = ((red_socks - x) + (blue_socks - x)) / 2;

    println!("{} {}", x, y)
}

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

fn main() {
    let reader = io::stdin();

    let parts:Vec<i8> =
            reader.lock()
            .lines().next().unwrap().unwrap()
            .split_whitespace()
            .filter(|s| !s.is_empty())
            .map(|s| s.parse::<i8>().unwrap())
            .collect();

    let a:i8 = parts[0];
    let b:i8 = parts[1];

    println!("{} {}", cmp::min(a, b), (a-b).abs() / 2 );

}

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

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

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

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let a = words[0];
    let b = words[1];

    println!("{} {}", std::cmp::min(a,b), i64::abs((a-b)/2));
}

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

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let arr : Vec<i32> = s.split_whitespace().map(|s| s.parse().unwrap()).collect();
    let (a, b, x) = (arr[0], arr[1], cmp::min(arr[0], arr[1]));
    println!("{} {}", x, (a + b - 2 * x) / 2);
}

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 _main() {
    let mut scan = Scan::new();
    let a: usize = scan.next();
    let b: usize = scan.next();
    let result1 = a.min(b);
    let result2 = (a.max(b) - result1) / 2;
    println!("{} {}", result1, result2);
}

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

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

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s)
        .expect("failed to read l2");

    let values = s
        .split_whitespace()
        .map(|x| x.parse::<i32>())
        .collect::<Result<Vec<i32>, _>>()
        .unwrap();

    assert!(values.len() == 2);
    let a = values[0];
    let b = values[1];

    let min = cmp::min(a,b);
    let rest_same_color_pairs = (cmp::max(a,b) - min) / 2;

    println!("{} {}", min, rest_same_color_pairs);
}

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 read_line_vec() -> Vec<i64> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn read_line_pair() -> (i64, i64) {
    let vec = read_line_vec();
    return (vec[0], vec[1]);
}

fn main() {

    let (a, b) = read_line_pair();

    let p1 = std::cmp::min(a, b);
    let p2 = ((a + b) - p1 - p1) / 2;

    println!("{} {}", p1, p2);

}