I am getting run time error.I even tried with taking array as long int and resr sum and ans as long long int.
hey @swatiguptasg, you need to add sum=sum%n; before sum=(sum+n)%n;