#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
long long read_long() {
  long long ans = 0;
  char c;
  bool started = false;
  bool is_negative = false;
  while (true) {
    c = getchar();
    if ((c < '0' || c > '9') && c != '-' && !started) continue;
    if ((c < '0' || c > '9') && c != '-' && started) break;
    if (started) {
      ans = ans * 10;
    }
    started = true;
    if (c == '-')
      is_negative = true;
    else
      ans += c - '0';
  }
  if (is_negative) ans *= -1;
  return ans;
}
int n;
int cnt[5][5];
int sum[5][5];
vector<int> g[5][5];
int used[5];
int mn[5][5];
int ans = 0;
void dfs(int v, int &second, int &deg) {
  used[v] = 1;
  int t = 0;
  for (int i = 0; i < 4; i++) {
    t += cnt[v][i];
    second += sum[v][i];
  }
  t %= 2;
  if (t) deg++;
  for (int i = 0; i < 4; i++) {
    if (cnt[v][i] && !used[i]) dfs(i, second, deg);
  }
}
void solve() {
  memset(used, 0, sizeof used);
  for (int i = 0; i < 4; i++) {
    if (!used[i]) {
      int deg = 0, second = 0;
      dfs(i, second, deg);
      if (deg <= 2) {
        ans = max(ans, second / 2);
      }
    }
  }
}
int main() {
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      mn[i][j] = inf;
    }
  }
  cin >> n;
  vector<int> edges;
  for (int i = 0; i < n; i++) {
    int x, val, y;
    cin >> x >> val >> y;
    if (x != y) edges.push_back(val);
    x--;
    y--;
    if (x > y) swap(x, y);
    cnt[x][y]++;
    sum[x][y] += val;
    cnt[y][x]++;
    sum[y][x] += val;
    mn[x][y] = min(mn[x][y], val);
    mn[y][x] = min(mn[y][x], val);
  }
  vector<pair<int, int> > e;
  for (int i = 0; i < 4; i++) {
    for (int j = i + 1; j < 4; j++) {
      e.push_back(make_pair(i, j));
    }
  }
  for (int mask = 0; mask < (1 << (int)e.size()); mask++) {
    int ok = 1;
    for (int i = 0; i < (int)e.size(); i++) {
      if (((1 << i) & mask) == 0) continue;
      int x = e[i].first, y = e[i].second;
      if (cnt[x][y] == 0) {
        ok = 0;
        break;
      }
    }
    if (!ok) continue;
    for (int i = 0; i < (int)e.size(); i++) {
      if (((1 << i) & mask) == 0) continue;
      int x = e[i].first, y = e[i].second;
      cnt[x][y]--;
      cnt[y][x]--;
      sum[x][y] -= mn[x][y];
      sum[y][x] -= mn[y][x];
    }
    solve();
    for (int i = 0; i < (int)e.size(); i++) {
      if (((1 << i) & mask) == 0) continue;
      int x = e[i].first, y = e[i].second;
      cnt[x][y]++;
      cnt[y][x]++;
      sum[x][y] += mn[x][y];
      sum[y][x] += mn[y][x];
    }
  }
  cout << ans << endl;
  return 0;
}
