How to use sum() in the main function please?