easy and concise solution(easily  understood able)
```\nclass Solution {\n    int mod = 1000000007;\n    public int firstDayBeenInAllRooms(int[] n) {\n        long data[] = new long[n.length],count=0L;\n        
```\nclass Solution {\n    int mod = 1000000007;\n    public int firstDayBeenInAllRooms(int[] n) {\n        long data[] = new long[n.length],count=0L;\n        Arrays.fill(data,0L);\n        long output = 0L;\n        for(int i=0;i<n.length-1;i++){\n            long temp = 0L;\n            temp = (2L+((i-1>=0?1L*data[i-1]:0L)-(n[i]-1>=0?1L*data[n[i]-1]:0L)))%mod;\n            data[i] = ((i-1>=0?data[i-1]:0)+(temp+mod)%mod)%mod;\n        }\n        return (int)(data[n.length-2]%mod);\n    }\n}
['Dynamic Programming', 'Java']