import java.util.Scanner;
/**
* Created by studyalgorithms
*/
class Problem1 {
public static void main
(String[] args
) {
Scanner sc
= new Scanner
(System.
in); long t = sc.nextLong();
for (long i = 0; i < t; i++) {
long n = sc.nextLong();
long a = 0, b = 0, d = 0;
// Here a, b and d are the count of numbers divisible by 3, 5 and 15 respectively
a = (n - 1) / 3;
b = (n - 1) / 5;
d = (n - 1) / 15;
// To get the sum of all numbers divisible by 3 (sum3) i.e. 3+6+9+-----+3n = 3(1+2+3+---+n) = 3*n(n+1)/2
// Similarly sum of all numbers divisible by 5 (sum5) is 5*n(n+1)/2
// Sum of numbers divisible by 15 (sum15) is 15*n(n+1)/2.
long sum3 = 3 * a * (a + 1) / 2;
long sum5 = 5 * b * (b + 1) / 2;
long sum15 = 15 * d * (d + 1) / 2;
long c = sum3 + sum5 - sum15;
}
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKLyoqCiAqIENyZWF0ZWQgYnkgc3R1ZHlhbGdvcml0aG1zCiAqLwpjbGFzcyBQcm9ibGVtMSB7CgogIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgIAogICAgU2Nhbm5lciBzYyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICBsb25nIHQgPSBzYy5uZXh0TG9uZygpOwogICAgZm9yIChsb25nIGkgPSAwOyBpIDwgdDsgaSsrKSB7CiAgICAgIGxvbmcgbiA9IHNjLm5leHRMb25nKCk7CiAgICAgIGxvbmcgYSA9IDAsIGIgPSAwLCBkID0gMDsKCiAgICAgIC8vIEhlcmUgYSwgYiBhbmQgZCBhcmUgdGhlIGNvdW50IG9mIG51bWJlcnMgZGl2aXNpYmxlIGJ5IDMsIDUgYW5kIDE1IHJlc3BlY3RpdmVseQogICAgICBhID0gKG4gLSAxKSAvIDM7CiAgICAgIGIgPSAobiAtIDEpIC8gNTsKICAgICAgZCA9IChuIC0gMSkgLyAxNTsKCiAgICAgIC8vIFRvIGd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