title: How to multiply two long values in java
body: <p>I am trying to multiply two largest numbers from an array of numbers. Its working fine for small numbers.</p>
  
  <p>Correct input / output - this is working:</p>
  
  <p>3 10 2 8 
     80</p>
  
  <p>Correct input / output - this is failing:</p>
  
  <pre><code>2 100000 90000
  9000000000
  </code></pre>
  
  <p>My output is however 10000000000 instead.</p>
  
  <p>Can someone tell me what is wrong in my code?</p>
  
  <pre><code>public static Long sumPairwise(Long[] numbers){
  
          int index=0;
          int n = numbers.length;
          for(int i=1;i&lt;n;i++){
              if(numbers[i]&gt;numbers[index])
                      index=i;
          }
          numbers[n-1]= numbers[index];
          index=0;
          for(int j=1;j&lt;n-1;j++){
          if(numbers[j]&gt;numbers[index])
                  index=j;
          }
          numbers[n-2]=numbers[index];
          Long product = (numbers[n-2])*(numbers[n-1]);
  
      return product ;
  }
  public static void main(String [] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Long numbers[] = new Long[n];
      for (int i=0;i&lt;n;i++)
      numbers[i]= sc.nextLong();
      System.out.println(sumPairwise(numbers));
  
  }
  </code></pre>