#include <bits/stdc++.h>
using namespace std;

int main() 
{
	long long int t,n; cin >> t;
	
	while(t--)
	{
	   cin >> n;
	   
	   if(n<11)
	   {cout << "NO" << endl; continue;}
	   
	   if(n%11 == 0 || n>1120 || n%111==0)
	   {cout << "YES" << endl; continue;}
	   
	   while(n>=11 && (n%11!=0 && n%111!=0))
	   n-=11;
	   
	   if(n>=11 && (n%11==0 || n%111==0))
	    {cout << "YES" << endl; continue;}
	    
	     cout << "NO" << endl; 
	}
	
	return 0;
}