Question: One of Scotland Yards most wanted criminal (Mister X) is on the run  and needs to reach a certain destination safely. There are three modes  of transport available for him - By air, by train or by cab.  With air  travel, he can go from station i to station i+3. Using a train would  make him reach station i+2 when starting from i and by taxi he could  go to the next station (i+1).Now, clearly there can be multiple ways of travelling between two  stations. Thus, you need to help him find out the total number of ways  of reaching station N from station 0. Since the number of ways can be  very large output the answer mod 109 +7.Input Specification:The first line contains the number of test cases, T. This is followed  by T lines each containing an integer N, the station ID.Output Specification:Print T lines, each line having the corresponding test case's output.Sample Input:2 3 4Sample Output:4 7Constraints:1 <= T <= 1000002 <= N <= 107My code to be optimized: import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class Solution {    public static void main(String[] args) throws IOException    {        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));         int testCases=Integer.parseInt(br.readLine());        short ways[]=new short[testCases],i=0;        int stationId;        while(testCases!=0)        {            stationId = Integer.parseInt(br.readLine());            ways[i++] = (short)(getWays(stationId)%(10^9 +7));            testCases--;        }           for(int k:ways)            System.out.println(k);    }    static int getWays(int n)    {        int sum = 1,i=1;        while(i<=n)        {            sum+=(i-1);            i++;        }        return sum;    }    }
Determine total number of ways of reaching a destination
java;optimization;complexity