\sum_i \min\left{(}\left{|}x_i-y_i\right{|},q-\left{|}x_i-y_i\right{|}\right{)}