I am trying to solve this question

and when i submit it I got partially correct (20 pts) . Here’s the code

#include <bits/stdc++.h>

using namespace std;

int main() {

unsigned long long int n,i,j,num; vector maxi,arr;

cin>>n;

// arr[n];

for(i=0;i<n;i++)

{

int NUM;

cin>>NUM;

arr.push_back(NUM);

}

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

num=arr[i]%arr[j];

maxi.push_back(num);

}

}

cout<<*max_element(maxi.begin(),maxi.end());

return 0;

}

What’s wrong in my code ? Thanks in advance