#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long minf = -(1e18);
long long arr[101];
bool search(long long low, long long high, long long elem) {
  while (low <= high) {
    int mid = (low + high) / 2;
    if (arr[mid] < elem) {
      low = mid + 1;
    } else if (arr[mid] == elem) {
      return 1;
    } else {
      high = mid - 1;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  sort(arr + 1, arr + n + 1);
  long long start = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] % 2 == 0) {
      if (!search(1, n, 3 * arr[i]) && !search(1, n, arr[i] / 2)) {
        start = arr[i];
        break;
      }
    } else {
      if ((!search(1, n, 3 * arr[i]))) {
        start = arr[i];
        break;
      }
    }
  }
  cout << start << " ";
  for (int i = 2; i <= n; i++) {
    if (start % 3 != 0) {
      cout << 2 * start << " ";
      start = 2 * start;
    } else {
      if (search(1, n, start / 3)) {
        cout << start / 3 << " ";
        start = start / 3;
      } else {
        cout << start * 2 << " ";
        start = start * 2;
      }
    }
  }
  return 0;
}
