#include using namespace std; #define rep(i,a,b) for(int i=a;i bool chmin(T &a,const T b){if(a>b){a=b;return 1;}return 0;} template bool chmax(T &a,const T b){if(a>N; vector> base={{1,1},{1,0}}; ll A=0,B=1; while(N){ if(N&1){ ll C=(A*base[0][0]+B*base[1][0])%mod; ll D=(A*base[0][1]+B*base[1][1])%mod; A=C,B=D; } N/=2; vector> tmp(2,vector(2)); rep(i,0,2) rep(j,0,2) rep(k,0,2){ tmp[i][j]=(tmp[i][j]+(base[i][k]*base[k][j]))%mod; } swap(tmp,base); } cout<<(A+B+mod-1)%mod<<"\n"; }