#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
void findLocation(int n, int first, int location[], int stype[])
{
stype[0] = 1;
location[0] = first;
int second = 0;
int mn = 1e9;
for(int i = 1;i<n;i++){
if(getDistance(0,i) < mn){
mn = getDistance(0,i);
second = i;
}
}
stype[second] = 2;
location[second] = location[0]+mn;
for(int i = 1;i<n;i++){
if(i == second) continue;
if(getDistance(0,i) < getDistance(second,i)){
stype[i] = 2;
location[i] = location[second] + getDistance(0,i);
}else{
stype[i] = 1;
location[i] = location[second] - getDistance(second,i);
}
}
}