#include <bits/stdc++.h>
#define REP(i, l, r) for (int i = (l); i <= (r); ++ i)
#define DEP(i, r, l) for (int i = (r); i >= (l); -- i)
#define fi first
#define se second
#define pb emplace_back
#define mems(x, v) memset((x), (v), sizeof(x))
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
namespace Milkcat {
typedef long long LL;
typedef pair<LL, LL> pii;
const int N = 1e6 + 5;
LL n, rs; vector<LL> s;
int main() {
cin >> n, rs = 0, s.clear();
for (LL i = 1; i * i <= n; i ++) {
if (n % i) continue;
s.pb(i), (i * i != n) && (s.pb(n / i));
}
LL lst = n + 1;
sort(ALL(s), greater<LL>());
for (LL x : s)
rs += n / x * (lst - x), lst = x;
cout << rs << '\n';
return 0;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T = 1; cin >> T;
while (T --) Milkcat::main();
return 0;
}