#include <bits/stdc++.h>
using namespace std;
int maks_dlu[2001];
int pozycja[2001];
int pop[2001];
int nast[2001];
set<int> secik;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int wynik = 0;
int n;
cin >> n;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
int z;
cin >> z;
maks_dlu[j]++;
if(z == 1)
{
maks_dlu[j] = 0;
}
}
for(int j = 0; j < n; j++)
{
auto it = secik.upper_bound(-maks_dlu[j]);
if(it != secik.end())
{
pop[j] = pozycja[-(*it)];
}
else
{
pop[j] = -1;
}
secik.erase(secik.begin(),it);
secik.insert(-maks_dlu[j]);
pozycja[maks_dlu[j]] = j;
}
secik.clear();
for(int j = n-1; j > -1; j--)
{
auto it = secik.upper_bound(-maks_dlu[j]);
if(it != secik.end())
{
nast[j] = pozycja[-(*it)];
}
else
{
nast[j] = n;
}
secik.erase(secik.begin(),it);
secik.insert(-maks_dlu[j]);
pozycja[maks_dlu[j]] = j;
}
secik.clear();
for(int j = 0; j < n; j++)
{
if(maks_dlu[j] != 0)wynik = max(wynik,(nast[j]-pop[j]-1)*maks_dlu[j]);
}
}
cout << wynik;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFrc19kbHVbMjAwMV07CmludCBwb3p5Y2phWzIwMDFdOwppbnQgcG9wWzIwMDFdOwppbnQgbmFzdFsyMDAxXTsKc2V0PGludD4gc2VjaWs7CgppbnQgbWFpbigpCnsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7Y2luLnRpZSgwKTtjb3V0LnRpZSgwKTsKICAgIGludCB3eW5payA9IDA7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykKICAgIHsKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgbjsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgaW50IHo7CiAgICAgICAgICAgIGNpbiA+PiB6OwogICAgICAgICAgICBtYWtzX2RsdVtqXSsrOwogICAgICAgICAgICBpZih6ID09IDEpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIG1ha3NfZGx1W2pdID0gMDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgbjsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgYXV0byBpdCA9IHNlY2lrLnVwcGVyX2JvdW5kKC1tYWtzX2RsdVtqXSk7CiAgICAgICAgICAgIGlmKGl0ICE9IHNlY2lrLmVuZCgpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwb3Bbal0gPSBwb3p5Y2phWy0oKml0KV07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwb3Bbal0gPSAtMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzZWNpay5lcmFzZShzZWNpay5iZWdpbigpLGl0KTsKICAgICAgICAgICAgc2VjaWsuaW5zZXJ0KC1tYWtzX2RsdVtqXSk7CiAgICAgICAgICAgIHBvenljamFbbWFrc19kbHVbal1dID0gajsKICAgICAgICB9CiAgICAgICAgc2VjaWsuY2xlYXIoKTsKICAgICAgICBmb3IoaW50IGogPSBuLTE7IGogPiAtMTsgai0tKQogICAgICAgIHsKICAgICAgICAgICAgYXV0byBpdCA9IHNlY2lrLnVwcGVyX2JvdW5kKC1tYWtzX2RsdVtqXSk7CiAgICAgICAgICAgIGlmKGl0ICE9IHNlY2lrLmVuZCgpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBuYXN0W2pdID0gcG96eWNqYVstKCppdCldOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgbmFzdFtqXSA9IG47CiAgICAgICAgICAgIH0KICAgICAgICAgICBzZWNpay5lcmFzZShzZWNpay5iZWdpbigpLGl0KTsKICAgICAgICAgICAgc2VjaWsuaW5zZXJ0KC1tYWtzX2RsdVtqXSk7CiAgICAgICAgICAgIHBvenljamFbbWFrc19kbHVbal1dID0gajsKICAgICAgICB9CiAgICAgICAgc2VjaWsuY2xlYXIoKTsKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgbjsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYobWFrc19kbHVbal0gIT0gMCl3eW5payA9IG1heCh3eW5paywobmFzdFtqXS1wb3Bbal0tMSkqbWFrc19kbHVbal0pOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgd3luaWs7Cn0K