#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int tt;
  cin >> tt;
  while (tt--) {
    long long n;
    cin >> n;
    long long m = 1;
    while ((m + 1) * (m + 1) <= n) {
      ++m;
    }
    long long res = n * n, cnt = n - m;
    vector<bool> b(m + 1);
    for (long long k = 2; k <= m; ++k) {
      if (b[k]) {
        continue;
      }
      DEBUG(k);
      long long l = 0;
      for (auto i = k; i <= n; i *= k) {
        if (i <= m) {
          b[i] = true;
        } else {
          --cnt;
        }
        ++l;
      }
      for (int j = 1; j <= l; ++j) {
        for (int i = 1; i <= j; ++i) {
          if (i == j) {
            res += n;
          } else {
            res += 2 * (n / (j / gcd(i, j)));
          }
        }
      }
    }
    res += cnt * n;
    cout << res << '\n';
  }
}