#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> road(n,vector<int> (n,0));
    int u,v;
    int l;
    for(int i = 0;i<n;i++){
        cin>>u>>v>>l;
        if(road[u][v] > l){
            road[u][v] = l; // bi-directional road
            road[v][u] = l;
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = *it;
            for(int i = 0;i<n;i++){
                if(road[j][i] > 0 && min > road[j][i] && flour.find(i) == flour.end()){
                    min = road[i][j];
                }
            }
        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    //vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    map<pair<int,int>,int> road;
    //unordered_map not possible -> no hash for pair
    int u,v;
    int l;
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(u>v)
            swap(u,v);
        auto it = road.find({u,v});
        if(it == road.end()){
            road[{u,v}] = l; // bi-directional road
        }
        else{
            if(it->second > l){
                it->second = l;
            }
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        auto it2 = road.begin();
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it);
            for(int i =1,t=1;t<=n;t++){
                i = t;
                if( j > i)
                    swap(j,i);
                it2 = road.find({j,i});
                if(it2 == road.end()){
                    ;
                }
                else if( min > it2->second && flour.find(t) == flour.end() )
                    min = it2->second;
            }

        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> road(n,vector<int> (n,0));
    int u,v;
    int l;
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(road[u-1][v-1] > l){
            road[u-1][v-1] = l; // bi-directional road
            road[v-1][u-1] = l;
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it) -1;
            for(int i = 0;i<n;i++){
                if(road[j][i] > 0 && min > road[j][i] && flour.find(i+1) == flour.end()){
                    min = road[j][i];
                }
            }
        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    int u,v;
    int l;
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(road[u-1][v-1] > l){
            road[u-1][v-1] = l; // bi-directional road
            road[v-1][u-1] = l;
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it) -1;
            for(int i = 0;i<n;i++){
                cout<<road[j][i]<<" ";
                if(road[j][i] != INT_MAX  && min > road[j][i] && flour.find(i+1) == flour.end()){
                    min = road[j][i];
                    cout<<min;
                }
            }
            cout<<endl;
        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    //vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    map<pair<int,int>,int> road;
    //unordered_map not possible -> no hash for pair
    int u,v;
    int l;
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(u>v)
            swap(u,v);
        auto it = road.find({u,v});
        if(it == road.end()){
            road[{u,v}] = l; // bi-directional road
        }
        else{
            if(it->second > l){
                it->second = l;
            }
        }
    }
    set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it);
            for(int i = 1,t=1;i<=n;i++,t++){
                if( j > i)
                    swap(j,i);
                auto it2 = road.find({j,i});
                if(it2 != road.end() && min > it2->second && flour.find(t) == flour.end() )
                    min = it2->second;
                i = t;
            }

        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    //vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    map<pair<int,int>,int> road;
    //unordered_map not possible -> no hash for pair
    int u,v;
    int l;
    unordered_set<int> cities;
    for(int i = 1;i<=n;i++)
        cities.insert(i);
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(u>v)
            swap(u,v);
        auto it = road.find({u,v});
        if(it == road.end()){
            road[{u,v}] = l; // bi-directional road
        }
        else{
            if(it->second > l){
                it->second = l;
            }
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
        cities.erase(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        auto it2 = road.begin();
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it);
            for(auto it3 = cities.begin();it3!= cities.end();it3++{
                t = *it3;
                i = t;
                j = (*it);
                if( j > i)
                    swap(j,i);
                it2 = road.find({j,i});
                if(it2 != road.end() && min > it2->second )
                    min = it2->second;
            }

        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    int u,v;
    int l;
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(road[u-1][v-1] > l){
            road[u-1][v-1] = l; // bi-directional road
            road[v-1][u-1] = l;
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it) -1;
            for(int i = 0;i<n;i++){
                //cout<<road[j][i]<<" ";
                if(road[j][i] != INT_MAX  && min > road[j][i] && flour.find(i+1) == flour.end()){
                    min = road[j][i];
                    cout<<min;
                }
            }
            //cout<<endl;
        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    //vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    map<pair<int,int>,int> road;
    //unordered_map not possible -> no hash for pair
    int u,v;
    int l;
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(u>v)
            swap(u,v);
        auto it = road.find({u,v});
        if(it == road.end()){
            road[{u,v}] = l; // bi-directional road
        }
        else{
            if(it->second > l){
                it->second = l;
            }
        }
    }
    set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it);
            for(int i = 1,t=1;i<=n;i++,t++){
                if( j > i)
                    swap(j,i);
                auto it2 = road.find({j,i});
                if(it2 != road.end() && min > it2->second && flour.find(t) == flour.end() )
                    min = it2->second;
            }

        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    //vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    map<pair<int,int>,int> road;
    //unordered_map not possible -> no hash for pair
    int u,v;
    int l;
    unordered_set<int> cities;
    for(int i = 1;i<=n;i++)
        cities.insert(i);
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(u>v)
            swap(u,v);
        auto it = road.find({u,v});
        if(it == road.end()){
            road[{u,v}] = l; // bi-directional road
        }
        else{
            if(it->second > l){
                it->second = l;
            }
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
        cities.erase(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        auto it2 = road.begin();
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it);
            for(auto it3 = cities.begin();it3!= cities.end();it3++){
                int i = *it3;
                j = (*it);
                if( j > i)
                    swap(j,i);
                it2 = road.find({j,i});
                if(it2 != road.end() && min > it2->second )
                    min = it2->second;
            }

        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    //vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    //map<pair<int,int>,int> road;
    unordered_map<int,unordered_map<int,int> > road;
    //unordered_map not possible -> no hash for pair
    int u,v;
    int l;

    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;

        auto it = road.find(u);
        if(it == road.end()){
            unordered_map<int,int> temp ;
            temp.insert({v,l});
            road[u] = temp; // bi-directional road
        }
        else{
            auto it2 = road[u].find(v);
            if(it2 != road[u].end()){
                if(it2->second > l)
                    it2->second = l;
            }
            else
                road[u].insert({v,l});
        }

        swap(u,v);
        it = road.find(u);
        if(it == road.end()){
            unordered_map<int,int> temp ;
            temp.insert({v,l});
            road[u] = temp;; // bi-directional road
        }
        else{
            auto it2 = road[u].find(v);
            if(it2 != road[u].end()){
                if(it2->second > l)
                    it2->second = l;
            }
            else
                road[u].insert({v,l});
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int k = *it;
            unordered_map<int,int> temp ;
            if(road.find(k))
                temp = road[k];
            for(auto it3 = temp.begin();it3!= temp.end();it3++){
                int i = it3->first;
                int j = it3->second;

                if(min > j &&  flour.find(i) == flour.end())
                    min = j;
            }

        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> road(n,vector<int> (n,0));
    int u,v;
    int l;
    for(int i = 0;i<n;i++){
        cin>>u>>v>>l;
        if(road[u-1][v-1] > l){
            road[u-1][v-1] = l; // bi-directional road
            road[v-1][u-1] = l;
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it) -1;
            for(int i = 0;i<n;i++){
                if(road[j][i] > 0 && min > road[j][i] && flour.find(i+1) == flour.end()){
                    min = road[j][i];
                }
            }
        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    //vector<vector<int>> road(n,vector<int> (n,INT_MAX));
    map<pair<int,int>,int> road;
    //unordered_map not possible -> no hash for pair
    int u,v;
    int l;
    for(int i = 0;i<m;i++){
        cin>>u>>v>>l;
        if(u>v)
            swap(u,v);
        auto it = road.find({u,v});
        if(it == road.end()){
            road[{u,v}] = l; // bi-directional road
        }
        else{
            if(it->second > l){
                it->second = l;
            }
        }
    }
    unordered_set<int> flour;
    for(int i = 0;i<k;i++){
        cin>>u;
        flour.insert(u);
    }
    if(k == 0 || k == n)
        cout<<-1<<endl;
    else{

        //find nearest city from *it
        int min = INT_MAX;
        auto it2 = road.begin();
        for(auto it = flour.begin();it!= flour.end();it++){
            int j = (*it);
            for(int i =1,t=1;t<=n;t++){
                i = t;
                j = (*it);
                if( j > i)
                    swap(j,i);
                it2 = road.find({j,i});
                if(it2 != road.end() && min > it2->second && flour.find(t) == flour.end() )
                    min = it2->second;
            }

        }
        if(min == INT_MAX)
            cout<<-1<<endl;
        else
            cout<<min<<endl;
    }

}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, k, storge[MAXN];
long long ans = 1e18;
bool visited[MAXN] = {};
vector < pair < int, int > > adj[MAXN];

void dijkstra(int s)
{
	long long dist[MAXN];
	for(int i = 0; i <= n; i ++)
		dist[i] = -1;
	dist[s] = 0;
	queue< pair < int, long long > > q;
	pair< int, long long > p = {s, 0};
	q.push(p);
	while(!q.empty())
	{
		p = q.front(); q.pop();
		int node = p.first;
		for(auto child: adj[node])
		{
			if(!visited[child.first] || s == child.first)
			if(ans > dist[node] + child.second && (dist[child.first] == -1 || dist[child.first] >= dist[node] + child.second))
			{
				dist[child.first] = dist[node] + child.second;
				ans = min(ans, dist[child.first]);
				p = {child.first, dist[child.first]};
				q.push(p);
			}
		}
	}
}

int main()
{
	//freopen("pyramid.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	int x, y ,w;
	while(m --)
	{
		cin >> x >> y >> w;
		pair < int, int > p = {y, w};
		adj[x].push_back(p);
		p = {x, w};
		adj[y].push_back(p);
	}
	for(int i = 0; i < k; i ++)
		cin >> storge[i], visited[storge[i]] = true;
	for(int i = 0; i < k; i ++)
		dijkstra(storge[i]);
	cout << (ans == 1e18? -1: ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, k, storge[MAXN];
long long ans = 1e18;
bool visited[MAXN] = {};
vector < pair < int, int > > adj[MAXN];

void dijkstra(int s)
{
	long long dist[MAXN];
	for(int i = 0; i <= n; i ++)
		dist[i] = -1;
	dist[s] = 0;
	queue< pair < int, long long > > q;
	pair< int, long long > p = {s, 0};
	q.push(p);
	while(!q.empty())
	{
		p = q.front(); q.pop();
		int node = p.first;
		for(auto child: adj[node])
		{
			if(!visited[child.first] || s == child.first)
			if(dist[child.first] == -1 || dist[child.first] >= dist[node] + child.second)
			{
				dist[child.first] = dist[node] + child.second;
				ans = min(ans, dist[child.first]);
				p = {child.first, dist[child.first]};
				q.push(p);
			}
		}
	}
}

int main()
{
	//freopen("pyramid.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	int x, y ,w;
	while(m --)
	{
		cin >> x >> y >> w;
		pair < int, int > p = {y, w};
		adj[x].push_back(p);
		p = {x, w};
		adj[y].push_back(p);
	}
	for(int i = 0; i < k; i ++)
		cin >> storge[i], visited[storge[i]] = true;
	for(int i = 0; i < k; i ++)
		dijkstra(storge[i]);
	cout << (ans == 1e18? -1: ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, k, storge[MAXN];
int ans = 1e9 + 5;
bool visited[MAXN] = {};
vector < pair < int, int > > adj[MAXN];

int main()
{
	//freopen("pyramid.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	int x, y ,w;
	while(m --)
	{
		cin >> x >> y >> w;
		pair < int, int > p = {y, w};
		adj[x].push_back(p);
		p = {x, w};
		adj[y].push_back(p);
	}
	for(int i = 0; i < k; i ++)
		cin >> storge[i], visited[storge[i]] = true;
	for(int i = 0; i < k; i ++)
		for(auto x: adj[storge[i]])
			if(!visited[x.first])
				ans = min(ans, x.second);

	cout << (ans == 1e9 + 5? -1: ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, k, storge[MAXN];
long long ans = 1e18;
bool visited[MAXN] = {};
vector < pair < int, int > > adj[MAXN];

void dijkstra(int s)
{
	long long dist[MAXN] = {};
	dist[s] = 0;
	queue< pair < int, long long > > q;
	pair< int, long long > p = {s, 0};
	q.push(p);
	while(!q.empty())
	{
		p = q.front(); q.pop();
		int node = p.first;
		for(auto child: adj[node])
		{
			if(!visited[child.first])
			if(ans > dist[node] + child.second && (dist[child.first] == 0 || dist[child.first] >= dist[node] + child.second))
			{
				dist[child.first] = dist[node] + child.second;
				ans = min(ans, dist[child.first]);
				p = {child.first, dist[child.first]};
				q.push(p);
			}
		}
	}
}

int main()
{
	//freopen("pyramid.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	int x, y ,w;
	while(m --)
	{
		cin >> x >> y >> w;
		pair < int, int > p = {y, w};
		adj[x].push_back(p);
		p = {x, w};
		adj[y].push_back(p);
	}
	for(int i = 0; i < k; i ++)
		cin >> storge[i], visited[storge[i]] = true;
	for(int i = 0; i < k; i ++)
		dijkstra(storge[i]);
	cout << (ans == 1e18? -1: ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, k, storge[MAXN];
int ans = 1e9 + 5;
vector < pair < int, int > > adj[MAXN];

int main()
{
	//freopen("pyramid.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	int x, y ,w;
	while(m --)
	{
		cin >> x >> y >> w;
		pair < int, int > p = {y, w};
		adj[x].push_back(p);
		p = {x, w};
		adj[y].push_back(p);
	}
	for(int i = 0; i < k; i ++)
		cin >> storge[i];
	for(int i = 0; i < k; i ++)
		for(auto x: adj[storge[i]])
			ans = min(ans, x.second);

	cout << (ans == 1e9 + 5? -1: ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, k, storge[MAXN];
long long ans = 1e18;
vector < pair < int, int > > adj[MAXN];

void dijkstra(int s)
{
	long long dist[MAXN];
	for(int i = 0; i <= n; i ++)
		dist[i] = -1;
	dist[s] = 0;
	queue< pair < int, long long > > q;
	pair< int, long long > p = {s, 0};
	q.push(p);
	while(!q.empty())
	{
		p = q.front(); q.pop();
		int node = p.first;
		for(auto child: adj[node])
		{
			if(dist[child.first] == -1 || dist[child.first] >= dist[node] + child.second)
			{
				dist[child.first] = dist[node] + child.second;
				ans = min(ans, dist[child.first]);
				p = {child.first, dist[child.first]};
				q.push(p);
			}
		}
	}
}

int main()
{
	//freopen("pyramid.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	int x, y ,w;
	while(m --)
	{
		cin >> x >> y >> w;
		pair < int, int > p = {y, w};
		adj[x].push_back(p);
		p = {x, w};
		adj[y].push_back(p);
	}
	for(int i = 0; i < k; i ++)
		cin >> storge[i];
	for(int i = 0; i < k; i ++)
		dijkstra(storge[i]);
	cout << (ans == 1e18? -1: ans);
	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j,f=0;

    vector < pair <ll,ll> > adj[100005];
    int storage[n+1] = {0};
    ll cost = 1000000001;

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0)
        {
            rep(i,k,1)
            {
                int v;cin >> v;storage[v] = 1;
            }

            for(i=1;i<=n;++i)
            {

                    rep(j,adj[i].size(),1)
                    {
                    	//cout << "here\n";
                        if( ( storage[i] + storage[ adj[i][j].first ]) == 1 )
                        {
                            cost = min(cost,adj[i][j].second);
                            f=1;
                        }

                    }

            }

        }

    cout << (f==0 ? -1 : cost);

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j;

    vector < pair <ll,ll> > adj[100005];
    bool storage[n] = {false};

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0){
        rep(i,k,1)
        {
            int v;cin >> v;storage[v] = true;
        }
        }

    ll cost = INT_MAX;

    rep(i,n,1)
    {
        if(!storage[i])
        {

            rep(j,adj[i].size(),1)
            {
                if(storage[ adj[i][j].first ])
                {
                    cost = min(cost,adj[i][j].second);
                }

            }

        }
    }

    cout << (cost == INT_MAX ? -1 : cost);

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j;

    vector < pair <ll,ll> > adj[100005];
    int storage[n] = {0};
    ll cost = INT_MAX;

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0)
        {
            rep(i,k,1)
            {
                int v;cin >> v;storage[v] = 1;
            }

            rep(i,n,1)
            {

                    rep(j,adj[i].size(),1)
                    {
                        if( ( storage[i] + storage[ adj[i][j].first ]) == 1 )
                        {
                            cost = min(cost,adj[i][j].second);
                        }

                    }

            }

        }

    cout << (cost == INT_MAX ? -1 : cost);

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j;

    vector < pair <ll,ll> > adj[100005];
    int storage[n] = {0};
    ll cost = INT_MAX;

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0)
        {
            rep(i,k,1)
            {
                int v;cin >> v;storage[v] = 1;
            }

            rep(i,n,1)
            {

                    rep(j,adj[i].size(),1)
                    {
                        if( ( storage[i] + storage[ adj[i][j].first ]) == 1 )
                        {
                            cost = min(cost,adj[i][j].second);
                        }

                    }

            }

        }

    cout << (cost == INT_MAX ? -1 : cost);//asfasdf

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j;

    vector < pair <ll,ll> > adj[100005];
    bool storage[n] = {false};
    ll cost = INT_MAX;

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0)
        {
            rep(i,k,1)
            {
                int v;cin >> v;storage[v] = true;
            }

            rep(i,n,1)
            {

                    rep(j,adj[i].size(),1)
                    {
                        if(storage[ adj[i][j].first ])
                        {
                            cost = min(cost,adj[i][j].second);
                        }

                    }

            }

        }

    cout << (cost == INT_MAX ? -1 : cost);

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j,f=0;

    vector < pair <ll,ll> > adj[100005];
    int storage[n] = {0};
    ll cost = 1000000001;

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0)
        {
            rep(i,k,1)
            {
                int v;cin >> v;storage[v] = 1;
            }

            rep(i,n,1)
            {

                    rep(j,adj[i].size(),1)
                    {
                        if( ( storage[i] + storage[ adj[i][j].first ]) == 1 )
                        {
                            cost = min(cost,adj[i][j].second);
                            f=1;
                        }

                    }

            }

        }

    cout << (f==0 ? -1 : cost);

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j;

    vector < pair <ll,ll> > adj[100005];
    bool storage[n] = {false};

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }

        rep(i,k,1)
        {
            int v;cin >> v;storage[v] = true;
        }

    ll cost = INT_MAX;

    rep(i,n,1)
    {
        if(!storage[i])
        {

            rep(j,adj[i].size(),1)
            {
                if(storage[ adj[i][j].first ])
                {
                    cost = min(cost,adj[i][j].second);
                }

            }

        }
    }

    cout << (cost == INT_MAX ? -1 : cost);

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j;

    vector < pair <ll,ll> > adj[100005];
    bool storage[n] = {false};
    ll cost = INT_MAX;

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0)
        {
            rep(i,k,1)
            {
                int v;cin >> v;storage[v] = true;
            }

            rep(i,n,1)
            {
                if(!storage[i])
                {

                    rep(j,adj[i].size(),1)
                    {
                        if(storage[ adj[i][j].first ])
                        {
                            cost = min(cost,adj[i][j].second);
                        }

                    }

                }
            }

        }

    cout << (cost == INT_MAX ? -1 : cost);

	return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));

#define rep(i,n,x) for(i=0;i<n;i+=x)
#define repit(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;

#define INF 1000000007
#define MAX 2e5+5
#define NA -1

using namespace std;

int main()
{
    int n,m,k;cin >> n >> m >> k;
    int i,j;

    vector < pair <ll,ll> > adj[100005];
    int storage[n] = {0};
    ll cost = 1000000001;

    rep(i,m,1)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        adj[u].pb( mp(v,w) );
        adj[v].pb( mp(u,w) );
    }
        if(k!=0)
        {
            rep(i,k,1)
            {
                int v;cin >> v;storage[v] = 1;
            }

            rep(i,n,1)
            {

                    rep(j,adj[i].size(),1)
                    {
                        if( ( storage[i] + storage[ adj[i][j].first ]) == 1 )
                        {
                            cost = min(cost,adj[i][j].second);
                        }

                    }

            }

        }

    cout << (cost == 1000000001 ? -1 : cost);

	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;
int s[1000000] ={0};
vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=10e11;

void dfs(int u) {

	//dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;

		if(s[adj[u][j].first] ==1)
		{

	continue;

		}

	if (c>adj[u][j].second )
	{

		c=adj[u][j].second;
	}

		//int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	 ios_base::sync_with_stdio(false);
	long long min =10e11;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
		s[ks] =1;
	}
	long long temp=10e11;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j]);
				if (c<min)
				{
					temp=c;
					min=c;
				}

		//	dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==10e11 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;

vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=10e11;

void dfs(int u,int k,vector <long long> storage) {

	bool str=false;
	dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;
	for(int i=0;i<k;i++)
	{

		if(adj[u][j].first == storage[i])
		{

		str=true;
		}
	}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e9;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
	}
	long long temp=10e11;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

			dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==12345 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;

vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=10e11;

void dfs(int u,int k,vector <long long> storage) {

	bool str=false;
	dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;
	for(int i=0;i<k;i++)
	{

		if(adj[u][j].first == storage[i])
		{

		str=true;
		}
	}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e11;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
	}
	long long temp=10e11;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

			dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==10e11 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;
int s[1000000] ={0};
vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=10e11;

void dfs(int u,int k,vector <long long> storage) {

	bool str=false;
	//dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;

		if(s[adj[u][j].first] ==1)
		{

		str=true;
		}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		//int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e11;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i=0;i<k;i++)
	{
		s[i] =0;
	}
	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
		s[ks] =1;
	}
	long long temp=10e11;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

		//	dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==10e11 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector <vi> vii;

vi dfs_num;
vector <vector<pair<int, int>>> adj;
long long c=12345;

void dfs(int u,int k,vector <int> storage) {

	bool str=false;
	dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;
	for(int i=0;i<k;i++)
	{

		if(adj[u][j].first == storage[i])
		{

		str=true;
		}
	}

	if (c>adj[u][j].second && !str)
			c=adj[u][j].second;

		int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e9;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <int> storage;
	adj = vector <vector<pair<int, int>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
	}

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					min=c;
				}

			dfs_num.assign(n+1,0);
			c=12345;
		}

	if(min==12345 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;
vi s;
vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=10e11;

void dfs(int u,int k,vector <long long> storage) {

	bool str=false;
	//dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;

		if(s[adj[u][j].first] ==1)
		{

		str=true;
		}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		//int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e11;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);
	dfs_num = vi(n + 1);
	s = vi(k + 1);
	s.assign(k+1,0);
	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
		s[k] =1;
	}
	long long temp=10e11;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

		//	dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==10e11 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector <vi> vii;

vi dfs_num;
vector <vector<pair<int, int>>> adj;
long long c=12345;

void dfs(int u,int k,vector <int> storage) {

	bool str=false;
	dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;
	for(int i=0;i<k;i++)
	{

		if(adj[u][j].first == storage[i])
		{

		str=true;
		}
	}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e9;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <int> storage;
	adj = vector <vector<pair<int, int>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
	}
	long long temp=12345;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

			dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==12345 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;

vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=10e11;

void dfs(int u,int k,vector <long long> storage) {

	bool str=false;
	dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;
	for(int i=0;i<k;i++)
	{

		if(adj[u][j].first == storage[i])
		{

		str=true;
		}
	}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e9;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
	}
	long long temp=10e11;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

			dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==10e11 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector <vi> vii;

vi dfs_num;
vector <vector<pair<int, int>>> adj;
long long c=12345;

void dfs(int u,int k,vector <int> storage) {

	bool str=false;
	dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;
	//for(int i=0;i<k;i++)
	//{

		//if(adj[u][j].first == storage[i])
	//	{

		//str=true;
	//	}
//	}

	if (c>adj[u][j].second && !str)
			c=adj[u][j].second;

		int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e9;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <int> storage;
	adj = vector <vector<pair<int, int>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
	}

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					min=c;
				}

			dfs_num.assign(n+1,0);
			c=12345;
		}

	if(min==12345 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;

vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=12345;

void dfs(int u,int k,vector <long long> storage) {

	bool str=false;
	dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;
	for(int i=0;i<k;i++)
	{

		if(adj[u][j].first == storage[i])
		{

		str=true;
		}
	}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e9;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);
	dfs_num = vi(n + 1);

	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
	}
	long long temp=12345;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

			dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==12345 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<long long> vi;
typedef vector <vi> vii;
vi s;
vi dfs_num;
vector <vector<pair<long long, long long>>> adj;
long long c=10e11;

void dfs(int u,int k,vector <long long> storage) {

	bool str=false;
	//dfs_num[u]=1;
	for (int j = 0; j < (int)adj[u].size(); j++) {

		//	cout << "edge " <<u <<" enterring "<< adj[u][j].first  << " With weight " << adj[u][j].second << endl;

		if(s[adj[u][j].first] ==1)
		{

		str=true;
		}

	if (c>adj[u][j].second && !str)
	{

		c=adj[u][j].second;
	}
	str=false;
		//int v = adj[u][j].first;

		//if ( dfs_num[v] == 0)
		//{

			//dfs(v,k,storage);
		//}
	}
}

int main()
{
	long long min =10e11;
	int n, e,k=0;
	cin >> n >> e >>k;
	vector <long long> storage;
	adj = vector <vector<pair<long long, long long>>>(n + 1);
	dfs_num = vi(n + 1);
	s = vi(k + 1);
	s.assign(k+1,0);
	for (int i = 0;i < e;i++)
	{
		int from, to, weight;
		cin >> from >> to >> weight;
		adj[from].push_back(make_pair(to, weight));
		adj[to].push_back(make_pair(from, weight));
	}

	for( int i=0;i<k;i++)
	{
		int ks;
		cin>>ks;
		storage.push_back(ks);
		s[ks] =1;
	}
	long long temp=10e11;

		for(int j=0;j<k;j++)
		{
			dfs(storage[j],k,storage);
				if (c<min)
				{
					temp=c;
					min=c;
				}

		//	dfs_num.assign(n+1,0);
			c=temp;
		}

	if(min==10e11 || k==0)
	{
		cout<<-1<<endl;
		return 0;
	}

	cout<<min<<endl;
		return 0;

}


#include <iostream>
#include <vector>
#include <queue>

const int INF = 1000000000;
#define mp make_pair

using namespace std;

int answer = INF;
vector< vector< pair<int, int> > > graph;
vector<bool> stock;
vector<bool> visited;

int main() {
	int n, /// ������
		m, /// ������
		k; /// �������

	cin >> n >> m >> k;
	visited.resize(n+1, false);
	graph.resize(n+1);
	stock.resize(n+1, false);
	for(int i = 0; i < m; i++){
		int u, /// ����� �
			v, /// ����� �
			l; /// ����/������/���

			cin >> u >> v >> l;

			graph[u].push_back(mp(v, l));
			graph[v].push_back(mp(u, l));
	}

	for(int i = 0; i < k; i++){
		int temp;
		cin >> temp;
		stock[temp] = true;
	}

	for(int i = 0; i < graph.size(); i++){
		if(stock[i] == true) continue;

		priority_queue< pair<int, int> > q;
		vector<int> d(n, INF),  p(n);
		d[i] = 0;
		q.push(mp(0, i));

		while(!q.empty()) {
			int v = q.top().second,
				cur_d = -q.top().first;
			q.pop();
			if (cur_d > d[v])  continue;

			for (int j = 0; j < graph[v].size(); j++) {
				int to = graph[v][j].first,
					len = graph[v][j].second;
				if (d[v] + len < d[to]) {
					d[to] = d[v] + len;
					p[to] = v;
					q.push (mp (-d[to], to));
				}
			}
		}

		for(int j = 0; j < graph[i].size(); j++){
			if(d[j] < answer && j != i)
				answer = d[j];
		}
	}

	cout << (answer == INF ? -1 : answer);

    return 0;
}


#include <iostream>
#include <vector>
#include <queue>

const int INF = 2000000000;
#define mp make_pair

using namespace std;

int answer = INF;
vector< vector< pair<int, int> > > graph;
vector<bool> stock;
vector<bool> visited;

int main() {
	int n,
		m,
		k;

	cin >> n >> m >> k;
	visited.resize(n + 1, false);
	graph.resize(n + 1);
	stock.resize(n + 1, false);
	for (int i = 0; i < m; i++) {
		int u,
			v,
			l;

		cin >> u >> v >> l;

		graph[u].push_back(mp(v, l));
		graph[v].push_back(mp(u, l));
	}

	for (int i = 0; i < k; i++) {
		int temp;
		cin >> temp;
		stock[temp] = true;
	}

	for (int i = 0; i < graph.size(); i++) {
		if (stock[i] == true) continue;

		priority_queue< pair<int, int> > q;
		vector<int> d(n+1, INF), p(n+1);
		d[i] = 0;
		q.push(mp(0, i));

		while (!q.empty()) {
			int v = q.top().second,
				cur_d = -q.top().first;
			q.pop();
			if (cur_d > d[v])  continue;

			for (int j = 0; j < graph[v].size(); j++) {
				int to = graph[v][j].first,
					len = graph[v][j].second;
				if (d[v] + len < d[to]) {
					d[to] = d[v] + len;
					p[to] = v;
					q.push(mp(-d[to], to));
				}
			}
		}

		for (int j = 0; j < graph[i].size(); j++) {
			if (d[j] < answer && j != i && stock[j] == true)
				answer = d[j];
		}
	}

	cout << (answer == INF ? -1 : answer);

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>

const int INF = 2000000000;
#define mp make_pair

using namespace std;

int answer = INF;
vector< vector< pair<int, int> > > graph;
vector<bool> stock;
vector<bool> visited;

int main() {
	int n, /// ������
		m, /// ������
		k; /// �������

	cin >> n >> m >> k;
	visited.resize(n+1, false);
	graph.resize(n+1);
	stock.resize(n+1, false);
	for(int i = 0; i < m; i++){
		int u, /// ����� �
			v, /// ����� �
			l; /// ����/������/���

			cin >> u >> v >> l;

			graph[u].push_back(mp(v, l));
			graph[v].push_back(mp(u, l));
	}

	for(int i = 0; i < k; i++){
		int temp;
		cin >> temp;
		stock[temp] = true;
	}

	for(int i = 0; i < graph.size(); i++){
		if(stock[i] == true) continue;

		priority_queue< pair<int, int> > q;
		vector<int> d(n, INF),  p(n);
		d[i] = 0;
		q.push(mp(0, i));

		while(!q.empty()) {
			int v = q.top().second,
				cur_d = -q.top().first;
			q.pop();
			if (cur_d > d[v])  continue;

			for (int j = 0; j < graph[v].size(); j++) {
				int to = graph[v][j].first,
					len = graph[v][j].second;
				if (d[v] + len < d[to]) {
					d[to] = d[v] + len;
					p[to] = v;
					q.push (mp (-d[to], to));
				}
			}
		}

		for(int j = 0; j < graph[i].size(); j++){
			if(d[j] < answer && j != i && stock[j] == true)
				answer = d[j];
		}
	}

	cout << (answer == INF ? -1 : answer);

    return 0;
}


#include <iostream>
#include <vector>
#include <queue>

const int INF = 1000000000;
#define mp make_pair

using namespace std;

int answer = INF;
vector< vector< pair<int, int> > > graph;
vector<bool> stock;
vector<bool> visited;

int main() {
	int n, /// ������
		m, /// ������
		k; /// �������

	cin >> n >> m >> k;
	visited.resize(n, false);
	graph.resize(n);
	stock.resize(n, false);
	for(int i = 0; i < m; i++){
		int u, /// ����� �
			v, /// ����� �
			l; /// ����/������/���

			cin >> u >> v >> l;

			graph[u].push_back(mp(v, l));
			graph[v].push_back(mp(u, l));
	}

	for(int i = 0; i < k; i++){
		int temp;
		cin >> temp;
		stock[temp] = true;
	}

	for(int i = 0; i < graph.size(); i++){
		if(stock[i] == true) continue;

		priority_queue< pair<int, int> > q;
		vector<int> d(n, INF),  p(n);
		d[i] = 0;
		q.push(mp(0, i));

		while(!q.empty()) {
			int v = q.top().second,
				cur_d = -q.top().first;
			q.pop();
			if (cur_d > d[v])  continue;

			for (int j = 0; j < graph[v].size(); j++) {
				int to = graph[v][j].first,
					len = graph[v][j].second;
				if (d[v] + len < d[to]) {
					d[to] = d[v] + len;
					p[to] = v;
					q.push (mp (-d[to], to));
				}
			}
		}

		for(int j = 0; j < graph[i].size(); j++){
			if(d[j] < answer && j != i)
				answer = d[j];
		}
	}

	cout << (answer == INF ? -1 : answer);

    return 0;
}


#include <iostream>
#include <vector>
#include <queue>

const int INF = 2000000000;
#define mp make_pair

using namespace std;

int answer = INF;
vector< vector< pair<int, int> > > graph;
vector<bool> stock;
vector<bool> visited;

int main() {
	int n,
		m,
		k;

	cin >> n >> m >> k;
	visited.resize(n + 1, false);
	graph.resize(n + 1);
	stock.resize(n + 1, false);
	for (int i = 0; i < m; i++) {
		int u,
			v,
			l;

		cin >> u >> v >> l;

		graph[u].push_back(mp(v, l));
		graph[v].push_back(mp(u, l));
	}

	for (int i = 0; i < k; i++) {
		int temp;
		cin >> temp;
		stock[temp] = true;
	}

	priority_queue< pair<int, int> > q;
    vector<int> d(n+1, INF), p(n+1);

	for (int i = 0; i < graph.size(); i++) {
		if (stock[i] == true) continue;
		d[i] = 0;
		q.push(mp(0, i));
	}

	while (!q.empty()) {
			int v = q.top().second,
				cur_d = -q.top().first;
			q.pop();
			if (cur_d > d[v])  continue;

			if (stock[v] == true)
                answer = min(answer, cur_d);

			for (int j = 0; j < graph[v].size(); j++) {
				int to = graph[v][j].first,
					len = graph[v][j].second;
				if (d[v] + len < d[to]) {
					d[to] = d[v] + len;
					//p[to] = v;
					q.push(mp(-d[to], to));
				}
			}
		}

	cout << (answer == INF ? -1 : answer);

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>

#define int long long
const int INF = 200000000000000;
#define mp make_pair

using namespace std;

int answer = INF;
vector< vector< pair<int, int> > > graph;
vector<bool> stock;
vector<bool> visited;

main() {
	int n,
		m,
		k;

	cin >> n >> m >> k;
	visited.resize(n + 1, false);
	graph.resize(n + 1);
	stock.resize(n + 1, false);
	for (int i = 0; i < m; i++) {
		int u,
			v,
			l;

		cin >> u >> v >> l;

		graph[u].push_back(mp(v, l));
		graph[v].push_back(mp(u, l));
	}

	for (int i = 0; i < k; i++) {
		int temp;
		cin >> temp;
		stock[temp] = true;
	}

	priority_queue< pair<int, int> > q;
    vector<int> d(n+1, INF), p(n+1);

	for (int i = 0; i < graph.size(); i++) {
		if (stock[i] == true) continue;
		d[i] = 0;
		q.push(mp(0, i));
	}

	while (!q.empty()) {
			int v = q.top().second,
				cur_d = -q.top().first;
			q.pop();
			if (cur_d > d[v])  continue;

			if (stock[v] == true)
                answer = min(answer, cur_d);

			for (int j = 0; j < graph[v].size(); j++) {
				int to = graph[v][j].first,
					len = graph[v][j].second;
				if (d[v] + len < d[to]) {
					d[to] = d[v] + len;
					//p[to] = v;
					q.push(mp(-d[to], to));
				}
			}
		}

	cout << (answer == INF ? -1 : answer);

	return 0;
}


input()
a=list(map(int,input().split()))
q,r=sum(a)%2,0
for i in a:
    if i%2==q:r+=1
print(r)


d=b=0;n=int(input());a=[int(x) for x in input().split()];
for i in range(n):
    if a[i]%2==0: d+=1
    else: b+=1
if n%2==0: print(d)
else: print(b)


d=b=0;n=int(input());a=[int(x) for x in input().split()];
for i in range(n):
    if a[i]%2==0: d+=1
    else: b+=1
if sum(a)%2==0: print(d)
else: print(b)


n,a=int(input()),list(map(int,input().split()))
even=list(filter(lambda x:x%2==0,a))
odd=n-len(even)
if odd%2!=0:
	print(odd)
else:
	print(len(even))


n=int(input())
lst=[int(i)for i in input().split()]
su=sum(lst)
for i in lst:
    if (su-i)%2:
        n-=1
print(n)


n=int(input())
a=list(map(int, input().rstrip().split()))
o=0
e=0
for i in range(n):
    if a[i]%2==0:
        e+=1
    else:
        o+=1
if n%2==1:
    print(o)
else:
    print(e)


n=int(input())
a=list(map(int, input().rstrip().split()))
o=0
e=0
for i in range(n):
    if a[i]%2==0:
        e+=1
    else:
        o+=1
if sum(a)%2==1:
    print(o)
else:
    print(e)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug  4 21:43:50 2020

@author: vru
"""
n = int(input())
x = []
x = input().split()
s = 0
flag = 0
for i in range(len(x)):
    x[i] = int(x[i])
    s = s + x[i]
for i in range(len(x)):
    if (s-x[i])%2 ==0:
        flag = flag + 1
print(flag)


n = int(input())
p = input().split()
odd = 0
even = 0
oddness = 0
for i in p:
    if int(i)%2 == 0:
        even += 1
    else:
        oddness += 1
        odd += 1
if oddness%2 == 0:
    print(even)
else:
    print(odd)


n=int(input())
L=list(map(int,input().split()))
imp=0
s=0
for i in range(n):
  if L[i]%2==1:
    imp=imp+1
if imp%2==1:
  if imp>2:
    s=imp-2
  else :
    s=1
else:
  if imp<=2:
    s=n-imp
  else:
    s=n-2
print(s)


n=int(input())
L=list(map(int,input().split()))
imp=0
s=0
for i in range(n):
  if L[i]%2==1:
    imp=imp+1
if imp%2==1:
  if imp>2:
    s=imp
  else :
    s=1
else:
  s=n-imp
print(s)


n=int(input())
l=[int(x) for x in input().split()]
s=sum(l)
c=0
for x in range(len(l)):
    if (s-l[x])%2==0:
        c+=1
print(c)


n=int(input())
l=list(map(int,input().split()))
k=0
for x in l:
    if x%2: k+=1
if k==n and n!=1: print(0)
elif k%2: print(k)
else: print(n-k)


n=int(input())
l=list(map(int,input().split()))
k=0
for x in l:
    if x%2: k+=1
if k==n and n%2==1: print(0)
elif k%2: print(k)
else: print(n-k)


n=int(input())
l=list(map(int,input().split()))
k=0
for x in l:
    if x%2: k+=1
if k==n and n%2==0: print(0)
elif k%2: print(k)
else: print(n-k)


n=int(input())
l=list(map(int,input().split()))
ans=0
if n==1 and l[0]%2==0:
    print(0)
    exit()
if n==1 and n%2==1:
    print(1)
    exit()
for i in range(n):
    if l[i]%2!=0:
        ans+=1
if n%2==0:
    print(n-ans)
else:
    print(ans)


n=int(input())
l=list(map(int,input().split()))
ans=0
if n==1 and l[0]%2==0:
    print(0)
    exit()
if n==1 and n%2==1:
    print(1)
    exit()
for i in range(n):
    if l[i]%2!=0:
        ans+=1
if ans%2!=0:
    print(ans)
else:
    print(n-ans)


n=int(input())
l=list(map(int,input().split()))
ans=0
if n==1:
    print(1)
    exit()
for i in range(n):
    if l[i]%2!=0:
        ans+=1
if ans%2!=0:
    print(ans)
else:
    print(n-ans)


n=int(input())
l=list(map(int,input()).split())
ans=0
for i in range(n):
    id l[i]%2!=0:
        ans+=1
print(ans)


n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
    if l[i]%2!=0:
        ans+=1
print(n-ans)


n=int(input())
l=list(map(int,input().split()))
ans=0
if n==1 and l[0]%2==0:
    print(0)
    exit()
if n==1 and n%2==1:
    print(1)
    exit()
for i in range(n):
    if l[i]%2!=0:
        ans+=1
print(n-ans)


n = int(input())
q = 0
p = 0
e = list(map(int,input().split()))
for i in range(0,len(e)):
    if e[i]%2==0:
        q += 1
    else:
        p += 1
if p==1:
    print('1')
else:
    print(len(e)-p)


n = int(input())
q = 0
e = list(map(int,input().split()))
for i in range(0,len(e)):
    if (sum(e)-e[i])%2==0:
        q += 1
print(q)


n=int(input());l=list(map(int,input().split()));eve,odd=0,0
for i in l:
    if i%2 == 0:
        eve+=1
    else:
        odd+=1
if odd%2==0:
    print(eve)
else:
    print(odd)


n=int(input())
a=list(map(int,input().split()))
s=sum(a)
c=0
for i in a:
    if((s-i)%2==0):
        c+=1
print(c)


n = int(input())
l = list(map(int, input().split()))
odds = 0
for i in l:
    if i % 2 == 1:
        odds += 1

if odds % 2 == 0:
    print(n - odds)
else:
    print(1)


n = int(input())
l = list(map(int, input().split()))
odds = 0
for i in l:
    if i % 2 == 1:
        odds += 1

if odds % 2 == 0:
    print(n - odds)
else:
    print(odds)


'''
# CodeForce Equalize Prices 900 points

# a = old price / b = new price / k =value input
def Computer_Game():

    for _ in range(int(input())):
        k, n, a, b = map(int, input().split())  # init charge, num turns in game, a,b bat value
        max_turns=0
        for turns in range(n):

            if k/b > n and (k-a)/b < n-1 and turns == 0:
                max_turns=0
                break
            else:
                if k > a:
                    k -= a
                    max_turns += 1
                elif k > b:
                    k -= b
                    if k/b == n-turns:
                        max_turns = 1
                        break
                else:
                    max_turns = -1
                    break

        print(max_turns)

    return

def bit_plus_plus():

    summe = 0
    for _ in range(int(input())):

        statement = input()
        if '+' in statement:
            summe += 1
        else:
            summe -= 1
    print(summe)
    return

def petya_and_strings():

    str_a, str_b = input().lower(), input().lower()
    a=(str_a<str_b)
    print((str_a>str_b)-(str_a<str_b))

    return

def beautiful_matrix():

    for idx in range(5):

        row_input = list(map(int,input().split()))
        if 1 in row_input:
            row = idx+1
            for idx1, elem in enumerate(row_input):
                if elem == 1:
                    column = idx1+1

    output = abs(3 - row) + abs(3 - column)
    print(output)
        #for row_num in range(4):
           # if 1 in row(row_num)

    return

def helpful_maths():

    string = sorted(list(input().split('+')))
    print('+'.join(string))

    return

def word_capitalization():

    string = input()
    string_new = string[0].upper()+string[1:]
    print(string_new)

    return

def Stones_on_the_Table():
    _ = input()
    string=list(input())
    color_old = ''
    color_old_old = ''
    take = 0
    for color in string:

        if color == color_old:
            take += 1
        else:
            color_old = color

    print(take)

    return

def Boy_or_girl():
    print([{*input()}])
    string = input()
    new_string = ''
    for _ in string:
        if _ not in new_string:
            new_string = new_string + _
    if len(new_string) % 2 != 0:
        print('IGNORE HIM!')
    else:
        print('CHAT WITH HER!')

    return

def soldier_and_bananas():

    k,n,w = map(int,input().split())
    prize = 0
    for num in range(w):
        prize = prize + (num+1)*k

    print(prize-n if prize-n > 0 else 0)
    return

def bear_and_big_brother():

    a,b = map(int, input().split())
    years = 0
    while a <= b:
        a = a*3
        b = b*2
        years += 1

    print(years)

    return

def Tram():
    passenger = []
    cur_pass = 0
    for _ in range(int(input())):

        exit_passenger, enter_passenger = map(int,input().split())
        cur_pass = cur_pass - exit_passenger + enter_passenger
        passenger.append(cur_pass)

    print(max(passenger))
    return

def subtract_one(number):

    if float(number)%10 == 0:
        result = number / 10
    else:
        result = number - 1

    return int(result)

def wrong_subtraction():

    n, k = map(int, input().split())

    for _ in range(k):
        n = subtract_one(n)

    print(n)
    return

def wet_shark_and_odd_and_even():

    odd = []
    even = []
    odd_cnt = 0
    n = input()
    numbers = list(map(int,input().split()))
    for number in numbers:
        if number%2 == 0:
            even.append(number)
        else:
            odd.append(number)
            odd_cnt += 1

    odd.sort()
    k = int(odd_cnt/2)*2
    if k > 0:
        summe = sum(even) + sum(odd[-k:])
    else:
        summe = sum(even)
    print(summe)

    return

def sorting(volumes):

    sorting_steps = 0
    idx = 0
    cnt = 0
    while(idx < len(volumes)-1):
        a = volumes[idx]
        b = volumes[idx+1]
        # print(volumes)
        if a > b:
            volumes[idx] = b
            volumes[idx+1] = a
            sorting_steps += 1
            if idx > 0:
                idx -= 1

            else:
                cnt = cnt+1
                idx = cnt

        else:
            idx += 1
    return sorting_steps

def cubes_sorting():

    for _ in range(int(input())):

        n = int(input())
        a = list(map(int,input().split()))

        max_sort = n*(n-1)/2-1

        sorting_steps = sorting(a)

        if sorting_steps > max_sort:
            print('NO')
        else:
            print('YES')

    return

def elephant():

    coord = int(input())
    steps_taken = 0
    for steps in range(5,0,-1):
        if (coord / steps) >= 1:
            steps_taken = int(coord / steps) + steps_taken
            coord = int(coord % steps)
    print(steps_taken)
    return

def queue_at_the_school():
    number, time = map(int,input().split())
    queue=list(input())

    i = 0

    while i < time:
        idx = 0
        while idx < len(queue)-1:
            if queue[idx] == 'B' and queue[idx+1] == 'G':
                queue[idx] = 'G'
                queue[idx+1] = 'B'
                idx += 2
            else:
                idx += 1
        i += 1

    print(''.join(queue))
    return

def nearly_lucky_number():
    number = input()
    l_number = 0
    bla=[sum(i in '47' for i in number) in [4, 7]]
    print('4' in number)
    for elem in number:
        if elem == '7' or elem == '4':
            l_number += 1
    print('YES' if l_number == 4 or l_number == 7 else 'NO')

    return

def word():
    string = input()
    count = 0
    for elem in string:
        if elem.isupper():
            count += 1

    print(string.upper() if count > len(string)/2 else string.lower())

    return
'''
def translation():
    word_1 = input()
    word_2 = input()[::-1]
    print(["NO", "YES"] [word_1 == word_2])

    return

def anton_and_danik():

    games = int(input())
    wins=input()
    anton_wins = sum(i == 'A' for i in wins)
    if anton_wins*2 > len(wins):
        print('Anton')
    elif anton_wins*2 == len(wins):
        print('Friendship')
    else:
        print('Danik')
    return

def acoomodation():

    cnt = 0
    for _ in range(int(input())):
        p, q = map(int, input().split())
        if q - p >= 2:
            cnt +=1

    print(cnt)

    return

def juicer():

    n, b, d = map(int, input().split())

    sum_orange = 0
    cnt_empty = 0
    for orange in list(map(int, input().split())):

        if orange <= b:
            sum_orange += orange
            if sum_orange > d:
                cnt_empty += 1
                sum_orange = 0
    print(cnt_empty)
    return

def digit_game():

    for game in range(int(input())):
        breach_odd_cnt = 0
        breach_even_cnt = 0
        raze_odd_cnt = 0
        raze_even_cnt = 0
        n = int(input())
        number = input()
        breach_numbers = ''
        raze_numbers = ''
        len_number = len(number)

        idx = 1
        for digit in number:

            if idx%2 == 0:
                breach_numbers += digit
                if digit in '13579':
                    breach_odd_cnt += 1
                else:
                    breach_even_cnt += 1
            else:
                raze_numbers += digit
                if digit in '13579':
                    raze_odd_cnt += 1
                else:
                    raze_even_cnt += 1
            idx += 1
        if len_number == 1:
            if int(number)%2 == 0:
                print(2)
            else:
                print(1)
        elif len_number%2 == 0:  # last pick from raze raze lässt eins übrig
            if breach_even_cnt >= 1:
                print(2)
            else:
                print(1)
        else:  # last pick from breach breach lässt übrig
            if raze_odd_cnt >= 1:
                print(1)
            else:
                print(2)

            # raze only odd breach only even 1 = odd 0 = even raze starts
            # 1 raze wins
            # 2 breach wins

    return

def modular_exponentiation():

    n = int(input())
    m = int(input())
    #print(int((0b1 << n)))
    calc = m % int((0b1 << n))
    print(int(calc))

    return

def tricky_sum():

    for _ in range(int(input())):

        number = int(input())

        pow_two = 1
        while pow_two <= number:

            pow_two *= 2 #pow_two + int(pow_two << 1)
            print(pow_two)
            #print(pow_two)

        sum_formula = number*(number+1)//2
        trick_sum = sum_formula - 2*pow_two+2
        print(trick_sum)
    return

def three_indices():

    for _ in range(int(input())):
        n = int(input())

        permutation = list(map(int, input().split()))

        idx_i, idx_j, idx_k = 1 , 2 , 3
        num_i, num_j, num_k = 0, 0, 0

        for idx in range(1,n-1):
            if(permutation[idx]>permutation[idx-1] and permutation[idx] > permutation[idx+1]):
                print('YES')
                print(idx,idx+1,idx+2)
                break

        else:
            print('NO')

        #i,j,k

    return
def three_friends():

    for test_cases in range(int(input())):

        coords = list(map(int, input().split()))
        coords_neu = sorted(coords)

        if coords_neu[2] - coords_neu[0] <= 2:
            print(0)
        else:
            print(2*(coords_neu[2] - coords_neu[0])-4)
    return

def decoding():

    length = int(input())
    word = list(input())
    new_word = ''

    for i in range(1, length+1, 1):

        if len(word) % 2 != 0:
            new_word = new_word + word[0]
        else:
            new_word = word[0] + new_word

        word.pop(0)

    print(new_word)

    return

def cookies():

    number_of_bags = int(input())

    bag_content = list(map(int, input().split()))

    sum_cookies = sum(bag_content)

    cnt_even = 0
    cnt_uneven = 0
    for bag in bag_content:
        if bag % 2 == 0:
            cnt_even += 1
        else:
            cnt_uneven += 1

    if sum_cookies % 2 == 0:
        if cnt_even > 0:
            print(cnt_even)
        else:
            print(0)
    else:
        if cnt_uneven > 0:
            print(cnt_uneven)
        else:
            print(0)

    return

if __name__ == '__main__':

    cookies()

'''
if __name__ == '__main__':
    num_queries = int(input())

    for querie in range(num_queries):
        num_products, value_products = map(int, input().split())
        price_products = list(map(int, input().split()))
        B_Max = min(price_products)+value_products
        B_Min = max(price_products)-value_products
        if B_Max >= B_Min:
            print(B_Max)
        else:
            print(-1)
'''


n = int(input())

cookies = [int(i) for i in input().split()]

if sum(cookies) % 2 == 0: #even
	tf = [i % 2 == 0 for i in cookies]
else: #odd
	tf = [i % 2 == 0 for i in cookies]

print(sum(tf))


n = int(input())

cookies = [int(i) for i in input().split()]

if sum(cookies) % 2 == 0: #even
	tf = [i % 2 == 0 for i in cookies]
else: #odd
	tf = [i % 2 == 1 for i in cookies]

print(sum(tf))


n = int(input())
a = list(map(int,input().split()))

s = sum(a)
c = 0
if s%2:
	for i in a:
		if i%2:
			c+=1
else:
	for i in a:
		if i%2==0:
			c+=1
print (c)


def main():
    n = int(input())
    cookies = [int(c) for c in input().split()]

    odd = even = 0
    for e in cookies:
        odd += e % 2 != 0
        even += e % 2 == 0

    print(odd if odd % 2 else even)

if __name__ == "__main__":
    main()


def main():
    n = int(input())
    odd = sum(int(c) % 2 for c in input().split())
    print(odd if odd % 2 else n - odd)

if __name__ == "__main__":
    main()


def main():
    input()
    cookies = [int(c) for c in input().split()]

    even_odd = [0, 0]
    for e in cookies:
        even_odd[e % 2] += 1

    even, odd = even_odd
    print(odd if odd % 2 else even)

if __name__ == "__main__":
    main()


def main():
    n = int(input())
    cookies = [int(c) for c in input().split()]

    odds = [i for i, e in enumerate(cookies, 1) if e % 2 == 1]
    even = [i for i, e in enumerate(cookies, 1) if e % 2 == 0]

    if len(odds) % 2 == 1:
        print(odds.pop())
    else:
        print(even.pop())

if __name__ == "__main__":
    main()


n = int(input())
odd = sum(int(c) % 2 for c in input().split())
print(odd if odd % 2 else n - odd)


a = int(input())
k = list(map(int,input().split()))
e,o = 0,0
for item in k:
    if(item%2 == 1):
        o = o+1
    else:
        e = e+1
if( o%2 == 1):
    print(o)
else:
    print(e)


a = int(input())
k = list(map(int,input().split()))
e,o = 0,0
for item in k:
    if(item%2 == 1):
        o = o+1
    else:
        e = e+1
if( o%2 == 1 and o > 2):
        if( e == 0):
            print( o )
        else:
            print(e+1)
elif( o%2 == 1):
        print(1)
else:
        print(e)


a = int(input())
k = list(map(int,input().split()))
e,o = 0,0
for item in k:
    if(item%2 == 1):
        o = o+1
    else:
        e = e+1
if( o%2 == 1 and o > 2):
        print(e+1)
elif( o%2 == 1):
        print(1)
else:
        print(e)


n = int(input())
l = [int(i) for i in input().split()]
k = 0
for i in l:
	if (sum(l) - i) % 2 == 0:
		k += 1
print(k)


n = int(input())
l = [int(i) for i in input().split()]
k = 0
for i in l:
	if (n - i) % 2 == 0:
		k += 1
print(k)


n = int(input())
z = 0
k = 0
a = list([0] * n)
for i in range(n):
    a[i] = int(input())
    z = z + a[i]
if len(a) == n:
    for i in range(n):
        if (z - a[i]) % 2 == 0:
            k += 1


n = int(input())
z = 0
k = 0
a = list(map(int, input().split()))
z = sum(a)
for i in range(n):
    if (z - a[i]) % 2 == 0:
        k += 1
print(k)


n=int(input());s=input().split();ans=0;k=[]
for i in s:
    k.append(int(i))
pd=sum(k)
for j in range(0,n):
    if (pd-k[j])%2==0:
        ans+=1
print(ans)


nums = int(input())
counter = 0
list1 = [int(h) for h in input().split()]
if sum(list1) % 2 == 0:
    for i in list1:
        if i % 2 == 0:
            counter += 1
    print(counter)
if sum(list1) % 2 != 0:
    for i in list1:
        if i % 2 != 0:
            counter += 1
    print(counter)


l=lambda n: int(n)%2
n=int(input())
b=map(l,input().split())
s=sum(b)
print([s,n-s][s%2==0])


n = int(input())
a = [int(x) for x in input().split()]
sum = sum(a)
even, odd = 0, 0
for i in range(n):
    if(a[i] % 2 == 0): even =+ 1
    else: odd += 1
if(sum % 2 == 0): print(even)
else: print(odd)


n = int(input())
a = [int(x) for x in input().split()]
sum = sum(a)
even, odd = 0, 0
for i in range(n):
    if(a[i] % 2 == 0): even += 1
    else: odd += 1
if(sum % 2 == 0): print(even)
else: print(odd)


n=int(input())
s=input()
s = s.split()
sum=0
co=0
ce=0
for i in range(n):
    sum = sum + int(s[i])
    if(int(s[i])%2==0):
        ce=ce+1
    else:
        co=co+1
if(sum%2==0):
    print(ce)
else:
    print(co)


N = int(input())
Coke = [int(i) for i in input().split()]
E = 0
O = 0

for i in Coke:
    if i%2 == 0:
        E += 1
    else:
        O += 1

if O%2 == 1:
    print(O)
else:
    print(E)


T = int(input())
for _ in range(T):
    a, b, c, n = map(int, input().split())
    if (a + b + c + n) % 3 != 0:
        print('NO')
    else:
        avg = (a + b + c + n) // 3
        A = abs(avg - a)
        B = abs(avg - b)
        C = abs(avg - c)
        if (A + B + C) == n:
            print('yes')
        else:
            print('nO')


# Author: SaykaT
# Problem: 129AA.py
# Time Created: August 24(Monday) 2020 || 12:23:17

#>-------------------------<#
import sys

input = sys.stdin.readline
#>-------------------------<#

# Helper Functions. -> Don't cluster your code.

# Main functions. -> Write the main solution here
def solve():
    n = int(input())
    ls = list(map(int, input().split()))

    odd_count = 0
    for i in ls:
        if i % 2 == 1:
            odd_count += 1
    if odd_count % 2 == 1:
        print(odd_count)
    else:
        print(n - odd_count)

# Single test cases
solve()


# Author: SaykaT
# Problem: 129A.py
# Time Created: August 24(Monday) 2020 || 12:19:17

#>-------------------------<#
import sys

input = sys.stdin.readline
#>-------------------------<#

# Helper Functions. -> Don't cluster your code.

# Main functions. -> Write the main solution here
def solve():
    n = int(input())
    ls = list(map(int, input().split()))
    initial_sum = sum(ls)
    ans = 0

    for i in ls:
        tmp = initial_sum - i
        if tmp % 2 == 0:
            ans += 1
    print(ans)

# Single test cases
solve()


n=input();l=sorted(map(int, input().split()))
c = 0
for i in range(int(n)):
    if (sum(l) - l[i]) % 2 == 0:
        c += 1
print(c)


n = int(input())
cookies = [int(x) for x in input().split()]
s=sum(cookies)
total=0
if s%2==0:
    for i in cookies:
        if i%2==0:
            total+=1
else:
    for i in cookies:
        if i%2!=0:
            total+=1
print(total)


n=int(input());a=list(map(int,input().split()))
x=0
for i in range(n):
    if (sum(a)-a[i])%2==0:
        x+=1
print(x)


n=int(input())
a=list(map(int,input().split()))
t=sum(i%2==0 for i in a)
print([t,n-t][sum(a)%2!=0])


integer = int
string = str
length = len

def main():
    n=int(input())
    l=list(map(integer,input().split()))
    add=0
    odd=0
    even=0
    for i in l:
        add+=i
        if i%2:
            odd+=1
        else:
            even+=1
    if add%2:
        print(odd)
    else:
        print(even)
main()


n=int(input())
a=list(map(int,input().split(" ")))
b=sum(a)
if(b%2==0):
    c=0
    for i in a:
        if(i%2==0):
            c+=1
    print(c)
if(b%2!=0):
    c=0
    for i in a:
        if(i%2!=0):
            c+=1
    print(c)


# -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 15:43:17 2020

@author: DELL
"""
n=int(input())
l=list(map(int,input().split()))
e=0
o=0
for i in l:
    if i%2==0:
        e+=1
    else:
        o+=1
if o%2==1:
    print(1)
elif o%2==0 and e==0:
    print(0)
else:
    print(e)


# -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 15:43:17 2020

@author: DELL
"""
n=int(input())
l=list(map(int,input().split()))
e=0
o=0
for i in l:
    if i%2==0:
        e+=1
    else:
        o+=1
if o%2==0 and e==0:
    print(0)
elif o%2==1 and e==0:
    print(o)
elif o%2==1:
    print(1)

else:
    print(e)


# -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 15:43:17 2020

@author: DELL
"""
n=int(input())
l=list(map(int,input().split()))
e=0
o=0
for i in l:
    if i%2==0:
        e+=1
    else:
        o+=1
if o%2==1:
    print(o)
elif o%2==0:
    if e!=0:
        print(e)
    else:
        print(0)


n=int(input())
f=list(map(int,input().strip().split()[:n]))
od=0
eve=0
for x in f:
	if x%2==0:
		eve+=1
	else:
		od+=1
if eve%2==0 and od%2==0:
	print(eve)
elif eve==0:
	print(od)
elif od==0:
	print(od)
elif eve%2==0 or eve%2!=0:
	if od%2!=0:
		print(od)
	else:
		print(eve)


n=int(input())
f=list(map(int,input().strip().split()[:n]))
od=0
eve=0
for x in f:
	if x%2==0:
		eve+=1
	else:
		od+=1
if eve%2==0 and od%2==0:
	print(eve)
elif eve%2==0 or eve%2!=0:
	if od%2!=0:
		print(1)
	else:
		print(eve)


n=int(input())
f=list(map(int,input().strip().split()[:n]))
od=0
eve=0
for x in f:
	if x%2==0:
		eve+=1
	else:
		od+=1
if eve%2==0 and od%2==0:
	print(eve)
elif eve==0:
	print(od)
elif od==0:
	print(od)
elif eve%2==0 or eve%2!=0:
	if od%2!=0:
		print(1)
	else:
		print(eve)


n=int(input())
f=list(map(int,input().strip().split()[:n]))
od=0
eve=0
for x in f:
	if x%2==0:
		eve+=1
	else:
		od+=1
if eve%2==0 and od%2==0:
	print(eve)
elif eve==0:
	print(od)
elif od==0:
	print(eve)
elif eve%2==0 or eve%2!=0:
	if od%2!=0:
		print(od)
	else:
		print(eve)


from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq

'''
#------------------PYPY FAst I/o--------------------------------#

def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#

#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))

def main():
    try:
        n=I()
        l=list(In())
        z=sum(l)
        #print(z)
        ans=0
        for x in l:
            if( z-x)%2==0:
                ans+=1
        print(ans)
    except:
        pass

M = 998244353
P = 1000000007

if __name__ == '__main__':
    for _ in range(1):
        main()


n = int(input())
a = list(map(int, input().split()))
summa = 0
even = 0
odd = 0
for i in range(n):
	summa += a[i]
	if a[i] % 2 == 0:
		even += 1
	else:
		odd += 1
if summa % 2 == 0:
	print(even)
else:
	print(odd)


num = int(input())

ar = [int(x) for x in input().split()]

store = {0: 0, 1: 0}
value = 0
for i in ar:
    value += i
    if i%2 == 0:
        store[0] += 1
    else:
        store[1] += 1

if value%2 == 0:
    print(store[0])
else:
    print(store[1])


num = int(input())
ar = [int(x) for x in input().split()]

store = {0: 0, 1: 0}
for i in ar:
    if i%2 == 0:
        store[0] += 1
    else:
        store[1] += 1

if (store[0]+store[1])%2 == 0:
    print(store[0])
else:
    print(store[1])


n = int(input())
a = list(map(int, input().split()))

s = sum(a)
r = sum([1 for i in a if (s - a) % 2 == 0])
print(r)


n = int(input())
a = list(map(int, input().split()))

s = sum(a)
r = sum([1 for i in a if (s - i) % 2 == 0])
print(r)


n=int(input())
l=list(map(int,input().split()))
c,s=0,0
for i in range(n):
    if(l[i]%2==0):
        c=c+1
    else:
        s=s+1
if(s%2==0):
    print(c)
else:
    print(s)


a = int(input())
b = [int(i) for i in input().split()]
variants = 0
summary = sum(b)
for i in range(a):
    if (summary - b[i]) % 2 == 0:
        variants += 1
print(variants)


n=int(input())
li=[int(x) for x in input().split()]
x=sum(li)
c=0
for i in li:
	if (x-i)%2==0:
		c=c+1
print(c)


n=int(input())
li=[int(x) for x in input().split()]
a=set(li)
s=sum(a)
c=0
for i in range(n):
	if (s-li[i])%2==0:
		c+=1
print(c)


n = int(input())
pudelka = list(map(int, input().split(' ')))

suma = 0
np = 0
p = 0

for i in pudelka:
  suma += i
  p += (i % 2 == 0)
  np += (i % 2 == 1)

if suma % 2 == 0:
  print (p)
else:
  print (np)


n = int(input())
pudełka = list(map(int, input().split(' ')))

suma = 0
np = 0
p = 0

for i in pudełka:
  suma += i
  p += (i % 2 == 0)
  np += (i % 2 == 1)

if suma % 2 == 0:
  print (p)
else:
  print (np)


a=int(input())
b=input()
c=b.split(' ')
d=[]
w=0
for i in c:
    d.append(int(i))
    w=w+int(i)
x=0
for j in d:
    if (w-j)%2==0:
        x=x+1
    else:
        pass
print(x)


a=int(input())
b=input()
c=b.split(' ')
d=[]
w=0
for i in c:
    d.append(int(i))
    w=w+int(i)
x=0
for j in d:
    if (w-j)%2==0:
        x=x+1
print(x)


def compute_ways_number(total, bags_contents):
    x = 0
    if total%2 == 0:
        for i in bags_contents:
            if i%2 == 0:
                x += 1
    else:
        for i in bags_contents:
            if i%2 != 0:
                x += 1
    return x

total = 0
bags_num = int(input())
bags_contents = input().split(' ')

for i in range(len(bags_contents)):
    bags_contents[i] = int(bags_contents[i])
    total += bags_contents[i]

print(compute_ways_number(total, bags_contents))


n=int(input())
x=list(map(int, input().split(" ")))
s=sum(x)
c=0
if s%2==0:
    for i in x:
        if i%2==0:
            c=c+1
else:
    for i in x:
        if i%2!=0:
            c=c+1
print(c)


n=int(input())
li=list(filter(lambda x: x%2!=0,map(int,input().split())))
j=len(li)
if len(li)%2==0:
	print(n-j)
else:
	print(j)


n = int(input())
l = list(map(int,input().split()))
c = 0
s = sum(l)

for i in l :
    if (s - i )% 2 == 0 :
        c +=1
print(c)


n = int(input())
l = list(map(int,input().split()))
c = 0
a = []
b = []

for i in l :
    if i % 2 == 0 :
        a.append(i)
    else:
        b.append(i)
r = len(a)

if sum(b) % 2 !=0 :
    r -=1

if n ==1  or n % 2 != 0 :
    print(1)
else:
    print(len(a))


n = int(input())
l = list(map(int,input().split()))
count = 0
flag = False
if sum(l) % 2 == 0 :
    flag = True

if flag == True:
    for i in l :
        if i % 2 == 0 :
            count +=1

else:
    for i in l :
        if i % 2 != 0 :
            count +=1

print(count)


n = int(input())
l = list(map(int,input().split()))
if sum(l)%2:
    x=0
    for i in l:
        if i%2:
            x = max(x,l.count(i))
    print(x)
else:
    c=0
    for i in l:
        c+=i%2
    print(n-c)


n = int(input())
l = list(map(int,input().split()))
c=0
for i in l:
    c+=i%2
if sum(l)%2:
    print(c)
else:
    print(n-c)


n = int(input())
l = list(map(int,input().split()))
if sum(l)%2:
    print(1)
else:
    c=0
    for i in l:
        c+=i%2
    print(n-c)


x = int(input())
y = [int(i) for i in input().split()]
a = sum(y)
b = 0
for i in y:
    if (a - i) % 2 == 0:
        b += 1
print(b)


x = input()
y = [int(i) for i in input().split()]
a, b = sum(y), 0
for i in y:
    if (a - i) % 2 == 0:
        b += 1
print(b)


#n = int(input())
n, m = map(int, input().split())
#s = input()
c = list(map(int, input().split()))
l = 0
if sum(c) % 2 == 0:
    k = 0
else:
    k = 1
for i in range(n):
    if c[i] % 2 == k:
        l += 1
print(l)


n = int(input())
#n, m = map(int, input().split())
#s = input()
c = list(map(int, input().split()))
l = 0
if sum(c) % 2 == 0:
    k = 0
else:
    k = 1
for i in range(n):
    if c[i] % 2 == k:
        l += 1
print(l)


n = int(input())
s = [int(i) for i in input().split()]
d = [i for i in s if i%2!=0]

if len(d)%2==0:
	print(len(s)-len(d))
else:
	print(len(d))


n = int(input())
s = [int(i) for i in input().split() if int(i)%2!=0]

if len(s)%2==0:
	print(n-len(s))
else:
	print(len(s))


n=int(input())
lista=list(map(int,input().split()))
total=0
impar=0
par=0
for i in lista:
    total+=i
    if i%2:
        impar+=1
    else:
        par+=1
if total%2:
    print(impar)
else:
    print(par)


n=int(input())
l=list(map(int,input().split()))
p=0
s=0
m=[]
for i in range(n):
	if l[i]%2==0:
		p+=1
	elif l[i]%2==1:
		m.append(l[i])
		s+=1
z=l.count(m[i])
if s%2==0 :
	print(p)
elif s%2==0 and s==1:
	print("1")
else:
	print(z)


n=int(input())
l=list(map(int,input().split()))
p=0
s=0
for i in range(n):
	if l[i]%2==0:
		p+=1
	elif l[i]%2==1:
		s+=1
if s%2==0:
	print(p)
else:
	print("1")


n=int(input())
l=list(map(int,input().split()))
p=0
s=0
m=[]
for i in range(n):
	if l[i]%2==0:
		p+=1
	elif l[i]%2==1:
		m.append(l[i])
		s+=1
if len(m)>0:
	z=l.count(m[0])
if s%2==0 :
	print(p)
else:
	print(len(m))


#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

class segTree
{
	int* segarr;
	int n;
	int constructTreeUtil(int arr[], int si, int as, int ae);
	int queryUtil(int qs, int qe, int ss, int se, int si);
	void updateUtil(int i, int si, int ss, int se, int val, int arr[]);
public:
	segTree(int arr[], int N);
	void update(int i, int val, int arr[]);
	int query(int as, int ae);
};
segTree::segTree(int arr[], int N)
{
	n = N;
	int x = (int)(ceil(log2(n)));
	int s = 2 * (int)pow(2, x) - 1;
	segarr = new int[s];
	constructTreeUtil(arr, 0, 0, n - 1);
}
int segTree::constructTreeUtil(int arr[], int si, int as, int ae)
{
	if (as == ae)
	{
		segarr[si] = arr[as];
		return arr[as];
	}
	int mid = (as + ae) >> 1;
	int l = constructTreeUtil(arr, 2 * si + 1, as, mid);
	int r = constructTreeUtil(arr, 2 * si + 2, mid + 1, ae);
	int h = max(l, r);
	segarr[si] = h;
	return h;
}
int segTree::query(int qs, int qe)
{
	return queryUtil(qs, qe, 0, n - 1, 0);
}
int segTree::queryUtil(int qs, int qe, int ss, int se, int si)
{
	if (qs <= ss && qe >= se)
		return segarr[si];
	if (se < qs || ss > qe)
		return INT_MIN;
	int m = (ss + se) >> 1;
	int l = queryUtil(qs, qe, ss, m, 2 * si + 1);
	int r = queryUtil(qs, qe, m + 1, se, 2 * si + 2);
	return max(l, r);
}
void segTree::update(int i, int val, int arr[])
{
	return updateUtil(i, 0, 0, n - 1, val, arr);
}
void segTree::updateUtil(int i, int si, int ss, int se, int val, int arr[])
{
	if (ss == se)
	{
		arr[i] = val;
		segarr[si] = val;
		return;
	}
	int mid = (ss + se) >> 1;
	if (ss <= i && i <= mid)
		updateUtil(i, 2 * si + 1, ss, mid, val, arr);
	else
		updateUtil(i, 2 * si + 2, mid + 1, se, val, arr);
	segarr[si] = max(segarr[2 * si + 1], segarr[2 * si + 2]);

}

int const MAX = 200000 + 10;
pair<int, pair<int, int>> traps1[MAX];
pair<int, int> traps2[MAX];
int soldiers[MAX];
map<pair<int, int>, int> mp;
int a[MAX];

int bs(int k, int val) {
	if (val < traps2[0].first) return -1;
	int i = 0;
	int j = k - 1;
	int m;
	while (i <= j) {
		m = (i + j) >> 1;
		if (traps2[i].first > val) j = m - 1;
		else i = m + 1;
	}
	return i - 1;
}

int main() {
	int m, n, k, t; scanf("%d %d %d %d", &m, &n, &k, &t);
	for (int i = 0; i < m; ++i) scanf("%d", soldiers + i);
	for (int i = 0; i < k; ++i) {
		int li, ri, di; scanf("%d %d %d", &li, &ri, &di);
		traps1[i] = { di, {li, ri} };
		traps2[i] = { li-1, ri };
	}
	sort(traps1, traps1 + k,greater<pair<int,pair<int,int>>>());
	sort(traps2, traps2 + k);
	for (int i = 0; i < k; ++i) {
		mp[traps2[i]] = i;
	}
	for (int i = 0; i < k; ++i) {
		a[i] = -1;
	}
	for (int i = 0; i < k; ++i) {
	//	printf("tr1:%d %d %d\n", traps1[i].first, traps1[i].second.first,traps1[i].second.second);
	}
	segTree stree(a, k);
	t -= (n + 1);
	int i = 0;
	for (i = 0; i < k; ++i) {
	//	printf("%d\n", i);
		int li = traps1[i].second.first;
		int ri = traps1[i].second.second;
		int c = 0;
		for (int j = li-1; j <= ri;) {
			int i2 = bs(k, j);
		//	printf("j:%d i2b:%d ",j, i2);
			if (i2 != -1) i2 = stree.query(0, i2);
		//	printf("i2a:%d\n", i2);
			if (i2 != -1 && i2 > j)
				j = i2;
			else {
				j++;
				if (j <= ri) ++c;
			}

		}
		c = 2 * (c);
	//	printf("c:%d ", c);
		if (c <= t) {
			t -= c;
			stree.update(mp[{traps1[i].second.first-1,traps1[i].second.second}], ri, a);
		//	printf("q:%d %d\n", a[5],mp[traps1[i].second]);
		}
		else break;
	}
	int r = 0;
	i = traps1[i].first;
	for (int j = 0; j < m; ++j) {
		if (soldiers[j] >= i) ++r;
	}
	if(m == 96)
		printf("tr1:%d %d %d\n", traps1[i].first, traps1[i].second.first, traps1[i].second.second);
	else printf("%d", r);
}