#include <bits/stdc++.h>
long long dp[5][4001];
int main() {
  dp[0][0] = 1;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j <= 4000; j++) {
      if (dp[i][j]) {
        for (int k = 0; k <= 1000; k++) dp[i + 1][j + k] += dp[i][j];
      }
    }
  int a;
  scanf("%d", &a);
  for (int i = 0; i < a; i++) {
    int b;
    scanf("%d", &b);
    printf("%lld\n", dp[4][b]);
  }
}
