1. #include <bits/stdc++.h>
  2. #define ll long long int
  3. #define ld long double
  4. using namespace std;
  5.  
  6. const ll N = 50010;
  7. const ll mod = 1e9 + 7;
  8. vector <long long> v;
  9. ll sum[N], squaresum[N];
  10.  
  11. void mainSolve()
  12. {
  13. ll n;
  14. cin >> n;
  15. int indx = upper_bound(v.begin(), v.end(), n) - v.begin() - 1;
  16. ll ans = (n * sum[indx] - squaresum[indx] + mod) % mod;
  17. cout << ans << '\n';
  18. }
  19.  
  20. int main()
  21. {
  22. #ifndef ONLINE_JUDGE
  23. freopen("input.txt", "r", stdin);
  24. freopen("output.txt", "w", stdout);
  25. #endif
  26. int t;
  27. cin >> t;
  28. for (int i = 1; i <= 100000; i++)
  29. {
  30. ll tmp = (i * (i - 1)) / 2;
  31. if (tmp > 1e9)
  32. break;
  33. v.push_back(tmp);
  34. }
  35. for (int i = 1; i < v.size(); i++)
  36. {
  37. sum[i] = sum[i - 1] + v[i];
  38. squaresum[i] = squaresum[i - 1] + v[i] * v[i];
  39. sum[i] %= mod;
  40. squaresum[i] %= mod;
  41. }
  42. while (t--)
  43. {
  44. mainSolve();
  45. }
  46. return 0;
  47. }