using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

namespace Contest
{

    class Program
    {
        private const long Mod = (long)1e9 + 7;
        private Scanner sc;
        private int N;
        private long[,] A;
        private long[] Memo;

        private long[] S;
        public void Solve()
        {
            sc = new Scanner();
            N = sc.NextInt();
            A = new long[N, N];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    A[i, j] = sc.NextInt();
                }
            }

            int max = 1 << N;
            Memo = new long[max];
            S = new long[max];
            for (int i = 0; i < max; i++)
            {
                Memo[i] = -1;
                S[i] = -1;
            }

            Console.WriteLine(Calc(max - 1));
        }

        private long Score(int n)
        {
            if (S[n] != -1)
            {
                return S[n];
            }

            long sum = 0;
            int index = -1;
            for (int i = 0; i < N; i++)
            {
                int bit = 1 << i;
                int and = n & bit;
                if (and > 0)
                {
                    if (index == -1)
                    {
                        index = i;
                    }
                    else
                    {
                        sum += A[i, index];
                    }
                }
            }

            long res;
            if (index == -1)
            {
                res = 0;
            }
            else
            {
                res = sum + Score(n - (1 << index));
            }

            S[n] = res;
            return res;
        }

        private long Calc(int n)
        {
            if (Memo[n] != -1)
            {
                return Memo[n];
            }

            int bitcnt = 0;
            for (int i = 0; i < N; i++)
            {
                int bit = 1 << i;
                int and = n & bit;
                if (and > 0) bitcnt++;
            }

            long ans = Score(n);
            int loop = 1 << (bitcnt - 1);
            for (int i = 1; i < loop; i++)
            {
                int a = 0;
                int b = 0;
                int cnt = 0;
                for (int j = 0; j < N; j++)
                {
                    int bb = 1 << j;
                    int aa = n & bb;
                    if (aa > 0)
                    {

                        int bit = 1 << cnt;
                        int and = i & bit;
                        if (and > 0)
                        {
                            a += bb;
                        }
                        else
                        {
                            b += bb;
                        }

                        cnt++;
                    }
                }
                //a += 1 << l[l.Count - 1];
                ans = Math.Max(ans, Calc(a) + Calc(b));
            }

            Memo[n] = ans;
            return ans;
        }


        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 13244