while (h = gets.to_i) && h != 0
  a = (1..h).inject([]){|a,b| a + [gets.split.map(&:to_i)]}
  puts (0...(1<<h)).map{|i|
    (0...(a[0].length)).inject(0){|s, j|
      s + (0...h).inject(0){|s, k| s + (((i >> k) & 1) ^ a[k][j])}
    }
  }.max
end