#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)2e18
#define _ <<' '<<
#define nl '\n'
void solve(){
int n, m, k;
cin>>n>>m>>k;
int c[n];
for(int i = 0; i < n; i++) cin>>c[i], c[i]--;
vector<int> g[n];
vector<pair<int,int>> ed(m);
for(auto &[x, y] : ed){
cin>>x>>y;
x--, y--;
g[x].push_back(y);
g[y].push_back(x);
}
int ans = 0;
// Length 2
for(auto [x, y] : ed){
if(c[x] != c[y]) ans++;
}
// Length 3
vector cnt(n, vector(5, 0));
for(int i = 0; i < n; i++){
for(int x : g[i]) cnt[i][c[x]]++;
for(int c1 = 0; c1 < 5; c1++){
for(int c2 = c1+1; c2 < 5; c2++){
if(c1 == c[i] or c2 == c[i]) continue;
ans += cnt[i][c1] * cnt[i][c2];
}
}
}
// Length 4
// for(auto [x, y] : ed){
// if(c[x] == c[y]) continue;
// for(int c1 = 0; c1 < 5; c1++){
// for(int c2 = 0; c2 < 5; c2++){
// if(c1 == c[x] or c1 == c[y] or c2 == c[x] or c2 == c[y] or c1 == c2) continue;
// ans += cnt[x][c1] * cnt[y][c2];
// }
// }
// }
// Length 5
// for(int i = 0; i < n; i++){
// for(int c1 = 0; c1 < 5; c1++){
// for(int c2 = 0; c2 < 5; c2++){
// if(c1 == c[i] or c2 == c[i] or c1 == c2) continue;
// for(int c11 = 0; c11 < 5; c11++){
// for(int c22 = 0; c22 < 5; c22++){
// if(c11 == c1 or c11 == c[i] or c11 == c2 or c22 == c1 or c22 == c[i] or c22 == c2 or c11 == c22) continue;
// ans +=
// }
// }
// }
// }
// }
cout<<ans * 2;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);cout.tie(NULL);
int t = 1;
//cin>>t;
while(t--) solve();
return 0;
}