#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  vector<vector<vector<pair<int, int>>>> b(
      n + 1, vector<vector<pair<int, int>>>(n + 1));
  for (int i = 0; i < m; i++) {
    int s, f, c, r;
    cin >> s >> f >> c >> r;
    b[s][f].emplace_back(c, r);
  }
  int mi = inf;
  long long ans = 0;
  for (int st = 1; st <= n; st++) {
    vector<vector<int>> f(n + 1, vector<int>(n + 1));
    for (int i = st + 1; i <= n; i++) {
      f[i][0] = a[i] - a[st];
      int now = st;
      for (int j = 1; j <= n; j++) {
        while (now < i && f[now + 1][j - 1] < a[i] - a[now + 1]) now++;
        f[i][j] = min(a[i] - a[now], f[now + 1][j - 1]);
      }
      for (auto [c, r] : b[st][i]) {
        ans = max(ans, 1LL * c * f[i][r]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
