#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, val, v;
};
int a[5][5];
edge e[105];
int used[5], deg[5];
int sumx, cnt;
void dfs(int x) {
  used[x] = 1;
  cnt++;
  for (int i = 1; i <= 4; i++) {
    if (a[x][i]) {
      sumx += a[x][i];
      if (!used[i]) dfs(i);
    }
  }
}
int main() {
  int n, minx, ans, flag;
  scanf("%d", &n);
  memset(a, 0, sizeof(a));
  memset(deg, 0, sizeof(deg));
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &e[i].u, &e[i].val, &e[i].v);
    a[e[i].u][e[i].v] += e[i].val;
    a[e[i].v][e[i].u] += e[i].val;
    deg[e[i].u]++;
    deg[e[i].v]++;
  }
  memset(used, 0, sizeof(used));
  ans = 0;
  for (int i = 1; i <= 4; i++) {
    if (!used[i]) {
      cnt = sumx = 0;
      dfs(i);
      sumx /= 2;
      if (cnt == 4) {
        flag = 1;
        for (int j = 1; j <= 4; j++) {
          if (deg[j] % 2 == 0) {
            flag = 0;
            break;
          }
        }
        if (flag) {
          for (int j = 1; j <= n; j++) {
            if (e[j].u != e[j].v) {
              a[e[j].u][e[j].v] -= e[j].val;
              a[e[j].v][e[j].u] -= e[j].val;
              memset(used, 0, sizeof(used));
              for (int k = 1; k <= 4; k++) {
                if (!used[k]) {
                  sumx = 0;
                  dfs(k);
                  sumx /= 2;
                  ans = max(ans, sumx);
                }
              }
              a[e[j].u][e[j].v] += e[j].val;
              a[e[j].v][e[j].u] += e[j].val;
            }
          }
          break;
        }
      }
      ans = max(ans, sumx);
    }
  }
  printf("%d\n", ans);
  return 0;
}
