The worst-case scenario is when at most two modules are working. To find this pair of working modules or ensure that it does not exist, one must pick all \frac{n(n-1)}{2} possible pairs of modules.
C++ implementation:
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
cout << n * (n-1) / 2;
}Python implementation:
n = int(input())
print (n * (n-1) // 2)