> System.out.println("総和=" + total + " 最後=" + i);
System.out.println("総和=" + total + " 最後=" + (i - 1)); かな。