Codingame - Algorithm successfully pass testcases but fail on submission : I recently got into Codingame and I'm trying to complete all the solo puzzles.

I'm kind of stuck on the Horse-racing one, the algorithm that I'm using is quite easy but for some reason it fails 2/8 of the submission validators (5 - All horses tie and 6 - Horses in disorder).

Can someone help me figure out what I'm doing wrong ?

    int main()
    {
        int N;
        cin >> N; cin.ignore();

        set<int> power;

        for (int i = 0; i < N; i++)
        {
            int Pi;
            cin >> Pi; cin.ignore();
            power.insert(Pi);
        }
    
        int minDiff = 10000000;
    
        auto i = power.begin();
    
        while (i != power.end())
        {
            minDiff = min(minDiff, abs(*i - *(++i)));
        }
        
        cout << minDiff << endl;
    }

