use std::{cmp, io, u32}; fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).expect("read error"); let n: u32 = s.trim().parse().expect("parse error"); let mut v = vec![0; 2usize.pow(n)]; for i in 0..n { s.clear(); io::stdin().read_line(&mut s).expect("read error"); for (j, x) in s.trim().split_whitespace().enumerate() { v[2usize.pow(i as u32) | 2usize.pow(j as u32)] = cmp::max(x.parse().expect("parse error"), 0); } } let mut m: u32 = 2; while m <= n { for i in 1..v.len() { for j in i+1..v.len() { let idx = i | j; if i.count_ones() + j.count_ones() == m && idx.count_ones() == m { v[idx] = cmp::max(v[idx], v[i] + v[j]); } } } m += 2; } println!("{}", v.last().unwrap()); }