def max_sum_rectangular_grid(grid, n):
    if n == 0:
        return 0
    if n == 1:
        return max(grid[0][0], grid[1][0])
    
    # For each column, the best value we can take from that column
    col_max = [max(grid[0][i], grid[1][i]) for i in range(n)]
    
    # dp[i] = max sum considering columns 0..i
    # We can't pick from two adjacent columns
    dp = [0] * n
    dp[0] = col_max[0]
    if n > 1:
        dp[1] = max(col_max[0], col_max[1])
    
    for i in range(2, n):
        dp[i] = max(dp[i-1], dp[i-2] + col_max[i])
    
    return dp[n-1]