#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX / 2;
class Solution {
 public:
  long long minimize(int n, int m, vector<int>& pos, vector<int>& from,
                     vector<int>& to, vector<int>& cost, vector<int>& limit) {
    vector<vector<int>> dp(n, vector<int>(n, INF));
    for (int i = 0; i < n; ++i) {
      dp[i][i] = 0;
    }
    vector<int> indices(m, 0);
    iota(indices.begin(), indices.end(), 0);
    auto cmp = [&](int l, int r) { return limit[l] < limit[r]; };
    sort(indices.begin(), indices.end(), cmp);
    int L = limit[indices.back()];
    long long res = 0;
    for (int l = 1, t = 0; l <= L + 1; ++l) {
      for (int i = n - 1; i >= 0; --i) {
        int r = i - 1;
        for (int j = i - 1; j >= 0; --j) {
          for (int k = r; k >= j; --k) {
            dp[j][i] = min(dp[j][i], max(dp[j][k], pos[i] - pos[k]));
            if (dp[j][k] >= pos[i] - pos[k]) {
              r = k;
            } else {
              break;
            }
          }
        }
      }
      while (t < m && limit[indices[t]] + 1 == l) {
        res = max(
            res, 1LL * cost[indices[t]] * dp[from[indices[t]]][to[indices[t]]]);
        ++t;
      }
    }
    return res;
  }
};
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution sol;
  int n, m;
  cin >> n >> m;
  vector<int> pos(n);
  for (int i = 0; i < n; ++i) {
    cin >> pos[i];
  }
  vector<int> from(m);
  vector<int> to(m);
  vector<int> cost(m);
  vector<int> limit(m);
  for (int i = 0; i < m; ++i) {
    cin >> from[i] >> to[i] >> cost[i] >> limit[i];
    --from[i];
    --to[i];
  }
  cout << sol.minimize(n, m, pos, from, to, cost, limit) << endl;
  return 0;
}
