Below is my code that I'm trying to run to solve for a maximum prioritized product problem i.e. return a maximum value for a product of two numbers in a list. My issue is that the product that is being computed is incorrect when the numbers in the input list are large. I was of the opinion that there will be no integer overflow in error and resulting product will be automatically long but that is not happening evidently as my multiplication is returning some kind of garbage.
#"python2"
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 28 17:12:38 2016
@author: pvatsa
"""
import numpy as np
n = int(raw_input())
alist = np.random.randint(100000, size = n)
print alist
assert(len(alist) == n)
alist = sorted(alist)
print alist
max_no = max(alist)
second_largest_no = alist[n-2]
print max_no*second_largest_no
#print long(product)
#print type(product)
alist = np.random.randint(100000, size = n, dtype = 'int64')