#include <bits/stdc++.h>
using namespace std;
const int MAX = 200001;
vector<vector<int> > adj;
int choice[MAX] = {
    0,
};
int root[MAX];
int parent[MAX][20];
int dep[MAX] = {
    0,
};
int mxEdge[MAX][20] = {
    0,
};
int dfn[MAX] = {
    0,
};
int timer = 0;
struct Edge {
  int u, v, cost, index;
  bool operator<(const Edge e) const {
    if (cost < e.cost) return true;
    return false;
  }
};
int find(int u) {
  if (u == root[u]) return u;
  return root[u] = find(root[u]);
}
void mrg(int u, int v) {
  u = find(u), v = find(v);
  if (u == v) return;
  root[u] = v;
}
void init() {
  for (int i = 0; i < MAX; i++) root[i] = i;
}
void dfs(int here, int dad, int d) {
  dep[here] = d;
  dfn[here] = ++timer;
  for (int i = 0; i < adj[here].size(); i++) {
    int there = adj[here][i];
    if (there == dad) continue;
    dfs(there, here, d + 1);
    parent[there][0] = here;
  }
}
int getLca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  int d = dep[v] - dep[u];
  int i = 0;
  while (d) {
    if (d & (1 << i)) {
      d -= (1 << i);
      v = parent[v][i];
    }
    i++;
  }
  if (u == v) return u;
  for (int i = 19; i >= 0; i--) {
    if (parent[v][i] != parent[u][i]) v = parent[v][i], u = parent[u][i];
  }
  return parent[u][0];
}
int main() {
  ios::sync_with_stdio(false);
  Edge edge[MAX];
  int n, m;
  cin >> n >> m;
  adj.resize(n + 1);
  long long sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> edge[i].u >> edge[i].v >> edge[i].cost;
    edge[i].index = i;
  }
  init();
  sort(edge + 1, edge + m + 1);
  for (int i = 1; i <= m; i++) {
    if (find(edge[i].u) == find(edge[i].v))
      continue;
    else {
      mrg(edge[i].u, edge[i].v);
      choice[edge[i].index] = 1;
      sum += edge[i].cost;
      adj[edge[i].u].push_back(edge[i].v);
      adj[edge[i].v].push_back(edge[i].u);
    }
  }
  dfs(1, -1, 0);
  parent[1][0] = -1;
  vector<long long> ans;
  for (int i = 1; i <= m; i++) {
    if (!choice[edge[i].index]) continue;
    if (dfn[edge[i].u] > dfn[edge[i].v]) {
      mxEdge[edge[i].u][0] = edge[i].cost;
    } else {
      mxEdge[edge[i].v][0] = edge[i].cost;
    }
  }
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      if (parent[j][i - 1] < 0) {
        parent[j][i] = -1;
        mxEdge[j][i] = -1;
      } else {
        parent[j][i] = parent[parent[j][i - 1]][i - 1];
        mxEdge[j][i] = max(mxEdge[j][i - 1], mxEdge[parent[j][i - 1]][i - 1]);
      }
    }
  }
  ans.resize(m + 1);
  for (int i = 1; i <= m; i++) {
    if (choice[edge[i].index]) {
      ans[edge[i].index] = sum;
    } else {
      int u, v, l;
      u = edge[i].u;
      v = edge[i].v;
      l = getLca(u, v);
      int diffu = dep[u] - dep[l];
      int diffv = dep[v] - dep[l];
      int mxu = 0, mxv = 0;
      int c = 0;
      int mxe = 0;
      while (diffu) {
        if (diffu & (1 << c)) {
          diffu -= (1 << c);
          mxu = max(mxu, mxEdge[u][c]);
          u = parent[u][c];
        }
        c++;
      }
      c = 0;
      while (diffv) {
        if (diffv & (1 << c)) {
          diffv -= (1 << c);
          mxv = max(mxv, mxEdge[v][c]);
          v = parent[v][c];
        }
        c++;
      }
      mxe = max(mxu, mxv);
      int cost = edge[i].cost;
      ans[edge[i].index] = sum + (edge[i].cost - mxe);
    }
  }
  for (int i = 1; i < ans.size(); i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
