main :: IO ()
main =
    print
        . head
        . filter isPrimeNaive
        $ [ sms ! (i, j) | j <- [ml - 1, ml - 2 .. 0], i <- [0 .. ml - j - 1] ]
  where
    primes' = getPrimesUpto lim
    ml      = length . takeWhile (<= lim) . scanl1 (+) $ primes'
    primes  = take ml primes'
    sms     = array
        ((0, 0), (ml - 1, ml - 1))
        (  zip (map (\i -> (i, 0)) [0 ..]) primes
        ++ [ ((i, j), sms ! (i, j - 1) + sms ! (i + j, 0))
           | i <- [0 .. ml - 1]
           , j <- [1 .. ml - i - 1]
           ]
        )
main :: IO ()
main =
    print
        . head
        . filter isPrimeNaive
        $ [ sms ! (i, j) | j <- [ml - 1, ml - 2 .. 0], i <- [0 .. ml - j - 1] ]
  where
    primes' = getPrimesUpto lim
    ml      = length . takeWhile (<= lim) . scanl1 (+) $ primes'
    primes  = take ml primes'
    sms     = array
        ((0, 0), (ml - 1, ml - 1))
        (  zip (map (\i -> (i, 0)) [0 ..]) primes
        ++ [ ((i, j), sms ! (i, j - 1) + sms ! (i + j, 0))
           | i <- [0 .. ml - 1]
           , j <- [1 .. ml - i - 1]
           ]
        )
main =
    print
        . head
        . filter isPrimeNaive
        $ [ sms ! (i, j) | j <- [ml - 1, ml - 2 .. 0], i <- [0 .. ml - j - 1] ]
  where
    primes' = getPrimesUpto lim
    ml      = length . takeWhile (<= lim) . scanl1 (+) $ primes'
    primes  = take ml primes'
    sms     = array
        ((0, 0), (ml - 1, ml - 1))
        (  zip (map (\i -> (i, 0)) [0 ..]) primes
        ++ [ ((i, j), sms ! (i, j - 1) + sms ! (i + j, 0))
           | i <- [0 .. ml - 1]
           , j <- [1 .. ml - i - 1]
           ]
        )