For this Question: There is circular river with circumference K. There are N cities on the banks of the river. The position p(i) of the i-th city is defined as its distance from the topmost point of the river in the clockwise manner.
You are given the positions of all the N cities, your task is to find the minimum distance you need to travel to visit all the N cities. You can start at whichever point you like, and can move both clockwise and anticlockwise around the river.

See sample for better understanding.

Topmost point here refers to one fixed point on the banks of the river.The first line of the input contains two number K and N.
The second line contains N singly spaced integers denoting the position of cities p(1), p(2),. , p(N).

Constraints
1 <= N <= 200000
1 <= K <= 1000000
0 <= p(1) < p(2) < p(3). . < p(N) < KOutput a single integer, the minimum distance you need to cover to visit all the N cities.Sample Input
20 3
0 5 15

Sample Output
10

Explanation: We start at 3rd city, then visit 1st city, then visit 2nd city. Total distance covered = 5 + 5 = 10.

Sample Input
20 3
5 10 15

Sample Output
10, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 200005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int arr[N];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int k, n; cin>>k>>n;

    For(i, 0, n){
        cin>>arr[i];
    }
    int ans = INF;
    For(i, 0, n){
        int j = (i-1+n)%n;
        int dist = (arr[j]-arr[i]+k)%k;
        ans = min(dist, ans);
    }
    cout<<ans;
    return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?