PLACE THE TILES problem in JAVA

Why am i getting wrong answer and TLE

import java.util.HashMap;
import java.util.Scanner;

public class Main {
public static void main(String agsp[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
System.out.println(fun(n));
}
public static long fun(int n){
HashMap<Integer,Long> map=new HashMap<>();
map.put(1,(long)1);
map.put(2,(long)2);
long sum=3;
for(int i=3;i<=n;i++){
map.put(i,sum);
sum+=map.get(i);
sum%=1000000007;
sum-=map.get(i-2);
map.remove(i-2);
sum%=1000000007;

        //System.out.print(dp[i]+" ");
    }
   // System.out.println();
    return map.get(n);
}

}

No reply???