#include <bits/stdc++.h>
using namespace std;
void setval(vector<int> &d, array<int, 3> &a, int k, int v) {
  for (int i = 0; i < d.size(); i++) {
    if (d[i] == k) {
      a[i] = v;
    }
  }
}
int getval(vector<int> &d, array<int, 3> &a, int k) {
  for (int i = 0; i < d.size(); i++) {
    if (d[i] == k) {
      return a[i];
    }
  }
  return k;
}
int main() {
  const long long inf = 1e18;
  int n;
  cin >> n;
  vector<int> a(n * 3);
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[j * 3 + i]);
    }
  }
  vector<pair<int, int>> es;
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < 3; y++) {
      if (y + 1 < 3) es.emplace_back(x * 3 + y, x * 3 + y + 1);
      if (x + 1 < n) es.emplace_back(x * 3 + y, x * 3 + y + 3);
    }
  }
  vector<int> deg(n * 3);
  for (auto e : es) {
    deg[e.first]++;
    deg[e.second]++;
  }
  vector<pair<array<int, 3>, long long>> dp;
  vector<int> fr = {0};
  dp.emplace_back(array<int, 3>{0, 0, 0}, 0);
  vector<pair<array<int, 3>, long long>> val;
  vector<int> fr1;
  for (auto e : es) {
    deg[e.first]--;
    deg[e.second]--;
    fr1.clear();
    for (int u : fr)
      if (deg[u] > 0) fr1.push_back(u);
    fr1.push_back(e.second);
    sort(fr1.begin(), fr1.end());
    fr1.erase(unique(fr1.begin(), fr1.end()), fr1.end());
    val.clear();
    for (auto kv : dp) {
      auto mate = kv.first;
      array<int, 3> mate1;
      for (int i = 0; i < fr1.size(); i++) {
        mate1[i] = fr1[i];
      }
      for (int i = 0; i < fr.size(); i++) {
        setval(fr1, mate1, fr[i], mate[i]);
      }
      val.emplace_back(mate1, kv.second);
      int mateu = getval(fr, mate, e.first);
      int matev = getval(fr, mate, e.second);
      if (mateu == -1 || matev == -1) continue;
      setval(fr1, mate1, e.first, -1);
      setval(fr1, mate1, e.second, -1);
      setval(fr1, mate1, mateu, matev);
      setval(fr1, mate1, matev, mateu);
      long long cost = 0;
      if (mateu == e.first) cost += a[mateu];
      if (matev == e.second) cost += a[matev];
      val.emplace_back(mate1, kv.second + cost);
    }
    sort(val.begin(), val.end());
    int i = 0;
    dp.clear();
    while (i < val.size()) {
      int j = i;
      long long mx = LLONG_MIN;
      while (i < val.size() && val[i].first == val[j].first) {
        mx = max(mx, val[i].second);
        i++;
      }
      bool ok = true;
      bool has0 = false;
      for (int u : fr1) {
        int v = getval(fr1, val[j].first, u);
        if (v == 0) has0 = true;
        if (u != v && v != -1 && v != 0 && deg[v] == 0) {
          ok = false;
        }
      }
      if (ok && has0) {
        dp.emplace_back(val[j].first, mx);
      }
    }
    swap(fr, fr1);
  }
  for (auto kv : dp) {
    auto mate = kv.first;
    if (getval(fr, mate, 3 * n - 1) == 0) {
      cout << kv.second << endl;
    }
  }
}
