#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return abs(a);
}
const int INF = 1e9 + 7;
const long long mod = 998244353;
const long long BIG_INF = 1e18 + 7;
const long long N = 1e6 + 7;
const unsigned int T = 1LL << 20;
const long double inf = 1e18;
const long double eps = 1e-14;
const int LOG = 20;
long long n, m, k;
int rep[N];
vector<vector<int> > G(N);
int Find(int x) { return x == rep[x] ? x : rep[x] = Find(rep[x]); }
void Union(int a, int b) {
  a = Find(a);
  b = Find(b);
  rep[a] = b;
}
int worek[N];
vector<vector<int> > zbiory(N);
int gdzie[N];
int bad[N];
map<pair<int, int>, vector<pair<int, int> > > kraw;
int odw[N];
void dfs(int start, int kol = 1) {
  odw[start] = kol;
  for (auto &u : G[start])
    if (odw[u] == odw[start])
      bad[gdzie[start]] = 1;
    else if (!odw[u])
      dfs(u, 3 - kol);
}
int kol(int kolor, int switched) { return switched ? 3 - kolor : kolor; }
void solve() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    rep[i] = i;
    cin >> gdzie[i];
  }
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    int x = min(gdzie[a], gdzie[b]);
    int y = max(gdzie[b], gdzie[a]);
    if (gdzie[a] == gdzie[b]) {
      G[a].push_back(b);
      G[b].push_back(a);
      Union(a, b);
    } else
      kraw[{x, y}].push_back({a, b});
  }
  for (int i = 1; i <= n; i++)
    if (!odw[i]) dfs(i);
  int ile_dobrych = 0;
  for (int i = 1; i <= k; i++)
    if (!bad[i]) ile_dobrych++;
  long long ans = 1ll * ile_dobrych * (ile_dobrych - 1) / 2;
  for (int i = 1; i <= n; i++) {
    worek[Find(i)] = Find(i);
    zbiory[Find(i)] = {Find(i)};
  }
  for (auto &u : kraw) {
    if (bad[u.first.first] or bad[u.first.second]) continue;
    map<int, int> switched;
    bool ok = 1;
    for (auto &kr : u.second) {
      int a = kr.first;
      int b = kr.second;
      int A = Find(kr.first);
      int B = Find(kr.second);
      int AAA = worek[A];
      int BBB = worek[B];
      if (AAA == BBB) {
        if (kol(odw[a], switched[A]) == kol(odw[b], switched[B])) ok = 0;
      } else {
        if ((int)(zbiory[AAA]).size() < (int)(zbiory[BBB]).size()) {
          swap(AAA, BBB);
          swap(A, B);
          swap(a, b);
        }
        if (kol(odw[a], switched[A]) == kol(odw[b], switched[B]))
          for (auto &v : zbiory[BBB]) switched[v] ^= 1;
        for (auto &v : zbiory[BBB]) {
          zbiory[AAA].push_back(v);
          worek[v] = AAA;
        }
      }
    }
    for (auto &kr : u.second) {
      int a = kr.first;
      int b = kr.second;
      worek[Find(a)] = Find(a);
      zbiory[Find(a)] = {Find(a)};
      worek[Find(b)] = Find(b);
      zbiory[Find(b)] = {Find(b)};
    }
    if (!ok) ans--;
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
}
