#include using namespace std; #define int long long #define app push_back #define all(x) (x).begin(),(x).end() #ifdef LOCAL #define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__) #else #define debug(...) #endif #ifdef LOCAL #define __int128 long long #endif // LOCAL const int inf=1e18; int p; int po(int a,int b) {if(b==0) {return 1;} if(b==1) {return a;} if(b%2==0) {int u=po(a,b/2);return (u*u)%p;} else {int u=po(a,b-1);return (a*u)%p;}} int inv(int x) {return po(x,p-2);} const int maxn=1e5+5; int arr[maxn];int f[maxn]; int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n;cin>>n>>p; for(int i=0;i<=n;++i) { for(int l=1;l<=n;++l) { for(int r=l;r<=n;++r) { int k=i/l; if(k*r>=i) { f[i]++; } } } } int invn=inv(n); int cur=1;for(int i=0;i=0;--i) {arr[i]+=arr[i+1];arr[i]%=p;} int res=0; for(int len=1;len<=n;++len) { int ways=arr[len-1]; for(int l=1;l<=n;++l) { for(int r=l+1;r<=n;++r) { res+=len*ways;res%=p; } } for(int l=1;l<=n;++l) { res+=(len/__gcd(l,len))*ways;res%=p; } } for(int i=0;i=0;--i) {arr[i]+=arr[i+1];arr[i]%=p;} for(int i=0;i<=n-1;++i) { int ways=arr[i]; res+=f[i]*ways;res%=p; } int c=1;for(int i=0;i