#include <bits/stdc++.h>
using namespace std;
template <typename T>
void __read(T &a) {
  cin >> a;
}
template <typename T, typename... Args>
void __read(T &a, Args &...args) {
  cin >> a;
  __read(args...);
}
constexpr long long M7 = 1000000007ll;
constexpr long long M9 = 1000000009ll;
constexpr long long MFFT = 998244353ll;
template <class T>
void outv(T &a) {
  for (auto &x : a) cout << x << ' ';
}
static mt19937 rnd(static_cast<unsigned>(
    chrono::steady_clock::now().time_since_epoch().count()));
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr));
int32_t main() {
  int n, m, k;
  __read(n, m, k);
  vector<int> c(n);
  vector<vector<int>> vByC(k);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    c[i]--;
    vByC[c[i]].push_back(i);
  }
  vector<pair<int, int>> e(m);
  map<pair<int, int>, vector<int>> eByC;
  for (int i = 0; i < m; ++i) {
    auto &[v, u] = e[i];
    cin >> v >> u;
    v--, u--;
    if (c[v] > c[u]) {
      swap(v, u);
    }
    eByC[pair<int, int>(c[v], c[u])].push_back(i);
  }
  vector<vector<int>> g(n);
  long long ans = (long long)k * (k - 1) / 2;
  vector<int> color(n, -1), compInd(n);
  vector<vector<int>> comp;
  function<bool(int)> dfs = [&](int v) {
    comp[compInd[v]].push_back(v);
    for (int u : g[v]) {
      if (color[u] != -1) {
        if (color[u] == color[v]) {
          return false;
        }
      } else {
        color[u] = color[v] ^ 1;
        compInd[u] = compInd[v] ^ 1;
        bool res = dfs(u);
        if (!res) {
          return false;
        }
      }
    }
    return true;
  };
  vector<int> bad(k);
  int cntBad = 0;
  for (int i = 0; i < k; ++i) {
    for (auto &j : eByC[pair<int, int>(i, i)]) {
      auto &[v, u] = e[j];
      g[v].push_back(u);
      g[u].push_back(v);
    }
    for (int v : vByC[i]) {
      if (color[v] == -1) {
        compInd[v] = comp.size();
        comp.emplace_back();
        comp.emplace_back();
        color[v] = 0;
        if (!dfs(v)) {
          cntBad++;
          bad[i]++;
          ans -= k - cntBad;
          break;
        }
      }
    }
    for (auto &v : vByC[i]) {
      g[v].clear();
    }
  }
  vector<vector<int>> ng(comp.size());
  for (int i = 0; i < ng.size(); i += 2) {
    ng[i].push_back(i + 1);
    ng[i + 1].push_back(i);
  }
  color.assign(ng.size(), -1);
  function<bool(int)> dfs2 = [&](int v) {
    for (int u : ng[v]) {
      if (color[u] != -1) {
        if (color[u] == color[v]) {
          return false;
        }
      } else {
        color[u] = color[v] ^ 1;
        bool res = dfs2(u);
        if (!res) {
          return false;
        }
      }
    }
    return true;
  };
  for (auto &[cc, ind] : eByC) {
    auto &[c1, c2] = cc;
    if (bad[c1] || bad[c2] || c1 == c2) {
      continue;
    }
    vector<int> order;
    for (auto &i : ind) {
      auto &[v, u] = e[i];
      ng[compInd[v]].push_back(compInd[u]);
      ng[compInd[u]].push_back(compInd[v]);
      order.push_back(compInd[v]);
      order.push_back(compInd[u]);
    }
    for (auto &v : order) {
      if (color[v] == -1) {
        color[v] = 0;
        if (!dfs2(v)) {
          ans--;
          break;
        }
      }
    }
    for (auto &v : order) {
      ng[v].resize(1);
      color[v] = -1;
      color[v ^ 1] = -1;
    }
  }
  cout << ans;
  return 0;
}
