#include <bits/stdc++.h>
using namespace std;
int m, n = 4;
vector<pair<int, int> > E[6];
int D[6][6];
vector<int> odd;
int Deg[6];
int dsu[6];
vector<int> g;
int idx = 0;
set<int> S;
int N[6][6];
int fx[6];
int f(int u) {
  if (dsu[u] != u) return dsu[u] = f(dsu[u]);
  return u;
}
int ff(int u) {
  if (fx[u] != u) return fx[u] = ff(fx[u]);
  return u;
}
int bridge(int a, int b) {
  for (int i = 1; i <= n; i++) fx[i] = i;
  if (N[a][b] > 1) return D[a][b];
  for (int i = 1; i <= n; i++) {
    for (auto e : E[i]) {
      if (i == a && b == e.first) continue;
      if (i == b && a == e.first) continue;
      int v = e.first;
      fx[ff(i)] = ff(v);
    }
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) ans.push_back(ff(i));
  sort(ans.begin(), ans.end());
  if (ans[0] == ans[1] && ans[1] == ans[2] && ans[2] != ans[3]) {
    int cnt = 0;
    for (auto e : E[ans[3]]) {
      int v = e.first;
      if (v == ans[3]) cnt += e.second;
    }
    return cnt / 2 + D[a][b];
  } else if (ans[0] != ans[1] && ans[1] == ans[2] && ans[2] == ans[3]) {
    int cnt = 0;
    for (auto e : E[ans[0]]) {
      int v = e.first;
      if (v == ans[0]) cnt += e.second;
    }
    return cnt / 2 + D[a][b];
  } else {
    return D[a][b];
  }
}
int main() {
  memset(D, -1, sizeof(D));
  for (int i = 1; i <= n; i++) dsu[i] = i;
  int ans = 0;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, v, b;
    scanf("%d%d%d", &a, &v, &b);
    if (a > b) swap(a, b);
    E[a].push_back(make_pair(b, v));
    E[b].push_back(make_pair(a, v));
    if (D[a][b] == -1 || D[a][b] > v) D[a][b] = D[b][a] = v;
    Deg[a]++;
    Deg[b]++;
    N[a][b]++;
    N[b][a]++;
    if (f(a) > f(b)) swap(a, b);
    dsu[f(a)] = f(b);
  }
  for (int i = 1; i <= n; i++) {
    S.insert(f(i));
  }
  for (auto it : S) {
    int root = f(it);
    g.clear();
    for (int i = 1; i <= n; i++) {
      if (f(i) == f(root)) {
        g.push_back(i);
      }
    }
    odd.clear();
    int tempans = 0;
    for (int i = 0; i < g.size(); i++) {
      if (Deg[g[i]] & 1) {
        odd.push_back(g[i]);
      }
    }
    for (int i = 0; i < g.size(); i++) {
      int u = g[i];
      for (auto e : E[u]) {
        tempans += e.second;
      }
    };
    if (odd.size() == 4) {
      int opt = 1e9;
      for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 4; j++) {
          if (D[odd[i]][odd[j]] != -1) opt = min(opt, bridge(odd[i], odd[j]));
        }
      }
      if (opt == 1e9) assert(1 == 2);
      tempans -= 2 * opt;
    }
    if (odd.size() & 1) assert(1 == 2);
    ans = max(ans, tempans / 2);
  }
  printf("%d\n", ans);
  return 0;
}
