title: Always getting the same answer in java
body: <p>Can anyone explain to me why I get only 40 as answer when I run the following code?</p>
  
  <p><a href="https://www.sololearn.com/coach/18?ref=app" rel="nofollow noreferrer">View problem in code coach</a></p>
  
  <pre class="lang-java prettyprint-override"><code>    import java.util.*;
      public class Program
      {
          public static void main(String[] args) {
              Scanner var = new Scanner (System.in);
              String n = var.nextLine();
              int p = var.nextInt();
              String[] a = var.nextLine().split(" ");
              List&lt;String&gt; list = new ArrayList&lt;String&gt;();
              for(int i=0;i&lt;a.length;i++){
                  list.add(a[i]);
              }
              list.add(n);
              Collections.sort(list);
              int y = list.indexOf(n)+1;
              if(y&gt;p){
                  System.out.print(((y/p)*20)+(y%p)*20);
              }
              else{
                  System.out.print("20");
              }
          }
      }
  </code></pre>