#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
vector<long long> ans(1000000+1,0);
long long int sum =0;
cin>>n;
for(int i = 1;i<=1000000;i++)
{
sum+=(i*(n+1)-n);
ans[i] = sum;
}
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
cout<<ans[n]<<endl;
}
}