OI IX - dzi

// https://szkopul.edu.pl/problemset/problem/VZifqMhw2OhTWnQqv7mC5Cge/site/?key=statement

// Działka

#include <bits/stdc++.h>

// #define GARY_DBG
#define GARY_LIB

constexpr int sizik = 1000 * 1001;

#define ar std::array

typedef std::vector<std::vector<int>> _kra;

void solve() {
    int n;
    std::cin >> n;

    int ans = 0;
    std::stack<std::pair<int, int>> S;
    std::vector<int> G(n + 2);
    for (int i = 1; i <= n; i++) {
        assert(S.empty());
        for (int j = 1; j <= n + 1; j++) {
            int x = 1;
            if (j <= n) {
                std::cin >> x;
            }

            // oblicz G[j]
            if (x == 1)
                G[j] = 0;
            else
                G[j]++;

            // popatrz na stosix
            int last = j;
            while (!S.empty() && S.top().second > G[j]) {
                ans = std::max(ans, (j - S.top().first) * S.top().second);
                last = S.top().first;
                S.pop();
            }

            if (j <= n) {
                if (G[j] > 0) {
                    S.push({last, G[j]});
                }
            }
        }
    }

    std::cout << ans << '\n';
}

int32_t main() {
#ifndef GARY_DBG
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
#endif

    int t = 1;
    // std::cin >> t;

    for (; t > 0; t--) {
        solve();
    }

    return 0;
}