Language: C++

#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
vector<int>array;

int main() {
	int dis;
	cin >> dis;
	array = vector<int>(dis);
	int max = 0;
	for(int n = 0;n < dis;n++) {
		cin >> array[n];
		if(max < array[n]) {
			max = array[n];
		}
	}
	int ans;
	int check;
	for(int n = 0;n < dis;n++) {
		ans += abs(array[n]-n-1);

	for(int l = -max;l < max+1;l++) {
		check = 0;
       	        for(int n = 0;n < dis;n++) {
			check += abs(array[n]-l-n-1);
		}
		if(ans > check) {
			ans = check;
		}
	}
	cout << ans  << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: reference to 'array' is ambiguous
   10 |         array = vector<int>(dis);
      |         ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:5:12: note:                 'std::vector<int> array'
    5 | vector<int>array;
      |            ^~~~~
a.cc:13:24: error: reference to 'array' is ambiguous
   13 |                 cin >> array[n];
      |                        ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:5:12: note:                 'std::vector<int> array'
    5 | vector<int>array;
      |            ^~~~~
a.cc:14:26: error: reference to 'array' is ambiguous
   14 |                 if(max < array[n]) {
      |                          ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:5:12: note:                 'std::vector<int> array'
    5 | vector<int>array;
      |            ^~~~~
a.cc:15:31: error: reference to 'array' is ambiguous
   15 |                         max = array[n];
      |                               ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:5:12: note:                 'std::vector<int> array'
    5 | vector<int>array;
      |            ^~~~~
a.cc:21:28: error: reference to 'array' is ambiguous
   21 |                 ans += abs(array[n]-n-1);
      |                            ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:5:12: note:                 'std::vector<int> array'
    5 | vector<int>array;
      |            ^~~~~
a.cc:26:38: error: reference to 'array' is ambiguous
   26 |                         check += abs(array[n]-l-n-1);
      |                                      ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:5:12: note:                 'std::vector<int> array'
    5 | vector<int>array;
      |            ^~~~~
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^