#include<iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int sum = 0;
for (int i = 1; i * i <= n; i++) {
if (n%i == 0) {
sum += i;
if (i != n/i) {
sum += n / i;
}
}
}
cout << sum - n << endl;
}
return 0;
}