#include <bits/stdc++.h>
using namespace std;
const int MAXN = 101;
const int MAXNODES = 5;
int N;
bool visit[MAXNODES];
int from[MAXN], to[MAXN], value[MAXN], degree[MAXNODES];
vector<int> G[MAXNODES][MAXNODES];
void input() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> from[i] >> value[i] >> to[i];
  }
}
void init(int u, int v) {
  for (int i = 1; i <= 4; i++) {
    degree[i] = 0;
    visit[i] = false;
    for (int j = 1; j <= 4; j++) {
      G[i][j].clear();
    }
  }
  for (int i = 1; i <= N; i++) {
    if (i == u || i == v) continue;
    G[from[i]][to[i]].push_back(value[i]);
    G[to[i]][from[i]].push_back(value[i]);
    degree[from[i]]++;
    degree[to[i]]++;
  }
}
void DFS(int node, int &oddDegree, long long &cur) {
  visit[node] = true;
  if (degree[node] % 2 == 1) oddDegree++;
  for (int nxt = 1; nxt <= 4; nxt++) {
    for (int add : G[node][nxt]) cur += add;
    if (visit[nxt] || G[node][nxt].empty()) continue;
    DFS(nxt, oddDegree, cur);
  }
}
long long solve(int u, int v) {
  init(u, v);
  long long ret = 0;
  for (int i = 1; i <= 4; i++) {
    if (!visit[i]) {
      int oddDegree = 0;
      long long cur = 0;
      DFS(i, oddDegree, cur);
      if (oddDegree <= 2) ret = max(ret, cur / 2);
    }
  }
  return ret;
}
void solve() {
  long long ans = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = i; j <= N; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  input();
  solve();
  return 0;
}
