#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000009;
int n, m;
int a[410];
pair<pair<int, int>, pair<int, int> > tr[250010];
int nowl;
int dp[410][410];
void cal() {
  for (int i = nowl; i <= n; i++) {
    dp[i][0] = a[i] - a[nowl];
  }
  for (int k = 1; k <= n; k++) {
    int j = n;
    for (int r = n; r > nowl; r--) {
      dp[r][k] = max(dp[j][k - 1], a[r] - a[j]);
      while (1) {
        if (j - 1 >= nowl) {
          int temp = max(dp[j - 1][k - 1], a[r] - a[j - 1]);
          if (temp <= dp[r][k]) {
            dp[r][k] = temp;
            j--;
          } else
            break;
        } else
          break;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= int(n); i++) {
    int x;
    cin >> x;
    a[i] = x;
  }
  for (int i = 0; i < int(m); i++) {
    int s, f, c, r;
    cin >> s >> f >> c >> r;
    tr[i] = make_pair(make_pair(s, f), make_pair(c, r));
  }
  sort(tr, tr + m);
  long long ans = -1;
  for (int i = 0; i < m; i++) {
    if (tr[i].first.first != nowl) {
      nowl = tr[i].first.first;
      cal();
    }
    long long temp =
        1LL * dp[tr[i].first.second][tr[i].second.second] * tr[i].second.first;
    ans = max(ans, temp);
  }
  cout << ans << endl;
}
