Place the tiles problem in JAVA. WHY getting wrong answer?

why getting wrong???
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=(long)3;
for(int i=3;i<=n;i++){
map.put(i,sum);
sum+=map.get(i);
sum-=map.get(i-2);
map.remove(i-2);
sum%=1000000007;
}

    return map.get(n)%1000000007;
}

}