#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define all(A) A.begin(), A.end()
typedef long long ll;
using P = pair<int, int>;

struct E
{
    int to, co;
    E(int a, int b)
    {
        to = a;
        co = b;
    }
};

struct node
{
    int dis, pos;
    node(int a, int b)
    {
        dis = a;
        pos = b;
    }
};

int n, m;
vector<vector<E>> g;
const int INF = (int)1e9;


void solve(int sv)
{
    vector<int> dist(n+1, INF);
    vector<bool> seen(n+1, 0);
    priority_queue<P, vector<P>, greater<P>> q;
    for (E next : g[sv])
    {
        if (next.co >= dist[next.to]){
            continue;
        }
        q.emplace(make_pair(next.co, next.to));
        dist[next.to] = next.co;
    }
    while (!q.empty())
    {
        node now = node(q.top().first, q.top().second);
        q.pop();
        for (E next : g[now.pos])
        {
            int this_route = now.dis + next.co;
            if (this_route >= dist[next.to])
            {
                continue;
            }
            q.emplace(make_pair(this_route, next.to));
            dist[next.to] = this_route;
        }
    }
    int ans = dist[sv];
    if (ans == INF)
    {
        ans = -1;
    }
    cout << ans << endl;
}

int main()
{
    cin >> n >> m;
    g.resize(n+1);
    rep(i, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        g[a].push_back(E(b, c));
    }
    rep1(sv, n)
    {
        solve(sv);
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef pair<int,char> pic;
typedef vector<pii> vpii;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repv(c, it) \
for(auto it = (c).begin(); it != (c).end(); it++)
#define repm(c, it) \
for(mll::iterator it = (c).begin(); it != (c).end(); it++)
const long long inf = 9223372036854775807;
#define pb push_back
const long long mod = 1000000007;
const double pi = acos(-1);








int main() {
 //decreases the time taken by cin,cout.
ios_base::sync_with_stdio(false); 
cin.tie(NULL);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif
    
    
    int n;cin>>n;

mii m;
    rep(i,0,n)
    {
        int x;cin>>x;
        if(m.find(x)==m.end()){m[x]=1;}
        else{cout<<"No";return 0;}
    }
    cout<<"Yes";

    return 0;
}


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 