#include <bits/stdc++.h>   using namespace std;   int arr[100000];   int pre[100000];   int leftMax;   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     ;     int t;     cin >> t;     while (t--) {       int maxLen = 0;       int n, x;       cin >> n >> x;       for (int i = 0; i < n; i++) cin >> arr[i];       pre[0] = arr[0];       for (int i = 1; i < n; i++) pre[i] = arr[i] + pre[i - 1];       leftMax = -1;       for (int i = 0; i < n; i++) {         pre[i] = pre[i] % x;         if (pre[i] != 0) maxLen = i + 1;         if (pre[i] != 0 && leftMax == -1) leftMax = i;       }       if (maxLen == 0)         cout <<  -1 n ;       else {         int finalLen = maxLen;         for (int i = 0; i < n; i++) {           if (pre[i] == 0)             finalLen = max(finalLen, max(abs(i - leftMax), abs(i - maxLen)));         }         cout << finalLen <<   n ;       }     }     return 0;   }   