#include <bits/stdc++.h>
using namespace std;
int n;
int ans;
void solve(int num, int sum, int d) {
  if (d == 4) {
    if (num == sum) {
      ans++;
    }
    return;
  }
  if (num < sum) return;
  if (num > (4 - d) * 1000 + sum) return;
  for (int i = 0; i < 1001; i++) {
    solve(num, sum + i, d + 1);
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    ans = 0;
    int a;
    cin >> a;
    solve(a, 0, 0);
    cout << ans << endl;
  }
  return 0;
}
