• + 0 comments

    // C++ 20........solution

    const int N = 100000; long long arr[N];

    long long gcd(long long a, long long b) { if(a < 0){ a = -a; }

    if(b < 0){
        b = -b;
    } 
    
    if(b>0){
          return gcd(b, a % b);
    
    }
    else{
        return a;
    }
    

    }

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */

    int n, q; 
        cin >> n;
        cin>> q;
    long long int  x;
    
    
    for(int i = 0; i < n; ++i) {
      cin >> x;
      arr[i] = x;
    }
    
    
    long long int  d = 0;
    
    for(int i = 0; i < n; ++i)
        d = gcd(d, arr[i] - arr[0]);
    
    while(q>0)
    {
        int k; cin >> k;
        cout << gcd(d, arr[0] + k) << '\n';
                q--;
    }
    
        return 0;
        }
    
    
    
    return 0;
    

    }