#include using namespace std; typedef std::map::iterator it_type; int main(){ int n; cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } std::map Map; for (int k=0;ksecond];it_type it1 = it; it1++; int val2 = a[it1->second]; MinVal = min(MinVal,abs(val2-val1)); } cout<first = key // iterator->second = value // Repeat if you also want to iterate through the second map. return 0; }