#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x % 3 && x / 3 < x % 3 * 2) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
    }
  }
  return 0;
}
